1.将多条数据合并为一条显示
SELECT '[ '+hName+' ]' FROM hobby FOR XML PATH('')
结果:
[ 爬山 ][ 游泳 ][ 美食 ]
2.去掉替换多余的字符
SELECT STUFF(( Select ','+Chemistry from #T FOR XML PATH('')),1,1,'')
结果:a,b,c,d
标签:xml,XML,hName,stuff,sql,PATH,path,SELECT
来源: https://www.cnblogs.com/lvxingzhewusheng/p/16578461.html