sql server 2017 STRING_AGG() 替代方案

 SELECT @StuId='"'+STRING_AGG(Id,'","')+'"'FROM( SELECT 'a'+cast(Id as varchar) Id from Student) AS TEStudent

可以用以下替代

  set @StuId=STUFF((select ','+Id from ( SELECT 'a'+cast(Id as varchar) Id from Student) as T FOR XML PATH('')),1,1,'')

posted @ 2020-08-25 14:27  摩诘  阅读(1803)  评论(0编辑  收藏  举报