select stuff(( select ','+UserName from tabname for xml path('')),1,1,'') as UserNamestr
注释:查询出tabname表中的UserName列的所有内容,并将内容拼接成UserNamestr