SQL Server 2005 合龙字段写法

SQL Server 2005 合并字段写法select id, [value] stuff((select , + [value] from tb where id t.i

SQL Server 2005 合并字段写法

select id, [value] = stuff((select ',' + [value] from tb where id = t.id for xml path('')) , 1 , 1 , '')from tb tgroup by id1   a1   b1   c1   d2   a2   b2   d结果:1    a,b,c,d2    a,b,d