SQL Server For XML 字段内容拼接

declare @tb table(F1 nvarchar(50),Gp nvarchar(50))
insert into @tb(F1,Gp)select 'a','A' union select 'a1','A' union select 'b','B' union select 'c1','c' union select 'c2','c'

select GP,(select distinct F1+' ' from @tb b where b.Gp=a.Gp for XML path(''))FED from @tb a
group by GP

posted on 2022-03-29 15:58  wakaka_wka  阅读(159)  评论(0编辑  收藏  举报