--多行数据分组后合并某个字段 declare @tabs table(tId int,name nvarchar(10)) insert @tabs values (1,'linda'), (1,'salar'), (2,'mom'), (2,'cc') select tId, stuff( (select '、'+name from @tabs where tId = t.tId for xml path('')),1,1,'' ) staffIds from @tabs t group by tId