SQLSERVER-分组数据字符串整合处理
Create table #temp([id] int,[name] nvarchar(1))
Insert #temp
select 1,N'a' union all
select 1,N'b' union all
select 2,N'c' union all
select 2,N'd' union all
select 2,N'e'
Go
Select ID,STUFF((SELECT ','+Name FROM #temp WHERE ID=t.ID FOR XML PATH('')) ,1,1,'') AS Name
from #temp AS t
GROUP BY ID