例如表
UserID
-------------------------------
C10000191
K16000003
K16000004
K16000006
K16000008
串联之后就是字符串: C10000191,K16000003,K16000004,K16000006,K16000008
--先找到前5条数据
select top 5 UserID Into #T1 from [GSDoorDB].[dbo].[Account_User]
declare @UserIDStr nvarchar(max)
set @UserIDStr =STUFF((select ',' + [UserID] from #T1 for xml path('')),1,1,'')
select @UserIDStr
drop table #T1
stuff函数去掉字符串最前面的逗号分隔符