If you pass a list of parent Ids as a table, then
with [CTE] as (
select * from [TheTable] c where c.[ParentId] IN (select ID from @ParentsList)
union all
select * from [CTE] p inner join [TheTable] c on c.[ParentId] = p.[NodeId]
)
select * from [CTE]
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles
No comments:
Post a Comment