stuff
时间:2011-04-08 来源:如歌
按CategoryID分组并排序,Names为相同的CategoryID的PropertyXngName以‘,’连接
select t.CategoryID,Names = stuff((select ',' +c.PropertyXngName from [develop].[dbo].[Xng_Properties] c where t.CategoryID = c.CategoryID for XML path('')) , 1 , 1 , '') from [develop].[dbo].[Xng_Properties] t Group by t.CategoryID order by t.CategoryID
相关阅读 更多 +