MSSQL如何将查询结果拼接成字符串

select SizeID,Matid,SizeCaption from mmfsize(nolock) where matid='000309' order by SizeID

select (select SizeCaption+',' from mmfsize(nolock) b where a.Matid=b.Matid order by b.SizeID for xml path('')) as SizeCaption
from MMFSize(nolock) a where a.Matid='000309' group by Matid

猜你喜欢

转载自www.cnblogs.com/wwwlzp/p/8964911.html
今日推荐