--用法如图 已, 分割 ''内存放数据
select STUFF((SELECT ',' + '"' + ISNULL(mtl_no,'') + '"' FROM SL_LOT_MTL_CHG_SUM_ITEM WITH(NOLOCK) WHERE doccode = '1513000003' FOR XML PATH('')),1,1,'') select *from SL_LOT_MTL_CHG_SUM_ITEM WHERE doccode = '1513000003'
按照某一字段 拼接 字符串
--用法如图 已, 分割 ''内存放数据 select refCodeitem, STUFF((SELECT ',' + '"' + ISNULL(ItemType,'') + '"' FROM imatdocitem a WHERE c.refCodeitem=a.refCodeitem and DocCode='SR00013214' FOR XML PATH('')),1,1,'' ) as nc from imatdocitem c where c.DocCode='SR00013214' group by c.refCodeitem
很好用
年与时驰,意与日去,遂成枯落,
多不接世,悲守穷庐,将复何及。