--SELECT ff= stuff((select ','+cast(WorkOrderNo as varchar)-- FROM dbo.TB_WorkOrder c -- where tpl.ProjectID=c.ProjectID -- WHERE c.WorkOrderType=1-- for xml path('')),1,1,'')
简单版的 SELECT a.CreateBy,Name =stuff((select ','+Name FROM SG_Client WHERE CreateBy = a.CreateBy for xml path('')),1,1,'')FROM SG_Client a group by a.CreateBy //连表查询 SELECT a.ContractID, LocationName =stuff( ( select ',' + LocationName FROM(select L.Na