Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.
WITH CategoryTree AS (SELECT r.catID, r.catName, 0 Level, r.parentID, CAST(r.catName AS NVarChar(Max)) AS "Path" FROM vwSelectPartCategory r WHERE r.parentID = 0 UNION ALL SELECT c.catID, c.catName, p.Level + 1 AS Level, c.parentID, CAST((p.path + ',' + c.catName) AS NVarChar(Max)) AS "Path" FROM vwSelectPartCategory c INNER JOIN CategoryTree p ON p.catID = c.parentID ) SELECT [Path] FROM CategoryTree Where 1 = 1 And (@CatID Is Null Or catID = @CatID) Order By [Path]
Join the community of 500,000 technology professionals and ask your questions.