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

posted on 2018-04-27 22:28  wwwlzp  阅读(944)  评论(0编辑  收藏  举报

导航