select ProjName,status from Project; --for xml path('') 是把得到的内容以XML的形式显示。 --stuff(param1, startIndex, length, param2) 将param1中自startIndex(SQL中都是从1开始,而非0)起,删除length个字符,然后用param2替换删掉的字符。 select ProjectName = ( stuff( (select '、' + ProjName from Project where Status = A.Status for xml path('')), 1, 1, '' ) ) from Project as A group by status;
xml path('')用法这里也详解:https://www.cnblogs.com/yuer20180726/p/11365498.html