SqlServer把选中结果每行连接起来中间用,隔开

模板:

declare  @columns nvarchar(100)

select @columns=stuff((select ','+ColumnName from [BattleFieldDisplay] where Category = @Category and IsShowChart = 1 for xml path('')),1,1,'')

例子:

select stuff((select ','+sname from stu for xml path('')),1,1,'')

 

posted @ 2022-04-19 14:31  点终将连成线  阅读(74)  评论(0编辑  收藏  举报