示例表 tb 数据如下 id value ----- 1 aa 1 bb 2 aaa 2 bbb 2 ccc SELECT id, [val] = ( SELECT [value] + ',' FROM tb AS b WHERE b.id = a.id FOR XML PATH('') ) FROM tb AS a 显示结果 1 aa,bb, 1 aa,bb, 2 aaa,bbb,ccc, 2 aaa,bbb,ccc, 2 aaa,bbb,ccc, SELECT id, [val]=( SEL…