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,'')