A field contents SQLServer multiple rows of data into a merged

select djid, pxId,
JgmData = (substring((select ',' + JgmData
from D_Gsp_HqJgm where DjId = a.DjId and PxId = a.PxId
for xml path('')),2,9999))
from (select distinct djId,pxId from D_Gsp_HqJgm ) a

 

 

for xml path: it is to show the query result set as XML, with which we can simplify our query to realize some of the previous function may need the help of live memory to complete the process work.

Guess you like

Origin www.cnblogs.com/ftian26977863/p/11815907.html