stuff

按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

posted @ 2011-04-08 13:05  如歌  阅读(216)  评论(0)    收藏  举报