You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在T-SQL中结合STRING_AGG与JSON_ARRAY时遇连接中断问题求助

问题:SQL Server中STRING_AGG嵌套JSON_ARRAY导致连接中断报错

执行以下T-SQL语句时出现连接中断问题:

SELECT 
    STRING_AGG(JSON_ARRAY(COL1, COL2, COL3 NULL ON NULL), ', ') 
FROM 
    {schema}.{table}

报错信息:

Msg 109, Level 20, State 0, Line 42

A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 0 - The pipe has been ended.)

环境信息:

  • SSMS 19.3
  • Microsoft SQL Server 2022 Express Edition (64-bit)
  • Windows Server 2016 Datacenter 10.0

当前可行的规避步骤:

  1. 使用JSON_ARRAY生成每行的JSON数组数据,存入临时表
  2. 对临时表中的数据执行STRING_AGG,将所有行合并为数组的数组

内容的提问来源于stack exchange,提问作者SirParser

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 02:17:05