SQL将某一字段多条记录合并为一个字段显示

select namelist=STUFF(REPLACE(REPLACE(( SELECT ID FROM [LotteryMatch] where GameDateTime > getdate() FOR XML AUTO ), '<LotteryMatch ID="', ','), '"/>', ''), 1, 1, '') from [LotteryMatch]

select namelist=STUFF(REPLACE(REPLACE(( SELECT ID FROM [LotteryMatch] where GameDateTime > getdate() FOR XML AUTO ), '<LotteryMatch ID="', ','), '"/>', ''), 1, 1, '') from [LotteryMatch]

原文地址:https://www.cnblogs.com/baobao2010/p/1773610.html