select a.Category, b.* from #temp a cross apply
(select ISNULL((
LTRIM(STUFF((SELECT
', ' + tTg.Category
FROM dbo.#temp (NoLock)tTg
WHERE tTg.ParentId = a.id FOR XML PATH('')),1,1,''))
),'') as Category) b
where a.ParentId = 0
(select ISNULL((
LTRIM(STUFF((SELECT
', ' + tTg.Category
FROM dbo.#temp (NoLock)tTg
WHERE tTg.ParentId = a.id FOR XML PATH('')),1,1,''))
),'') as Category) b
where a.ParentId = 0
No comments:
Post a Comment