Created
August 12, 2014 09:43
-
-
Save elw00d/11038f43e61195b37e5f to your computer and use it in GitHub Desktop.
Recursive CTE SQL Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with cte as ( | |
select id, parentId, name from Category where id = 17 | |
union all | |
select c.id, c.parentId, c.name from Category c | |
join cte on c.id = cte.parentId | |
) select * from cte |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment