And just to make sure it works if its a parent of itself (otherwise it will recurse until it breaks):
with [CTE] as (
select * from [TheTable] c where c.[ParentId] = 1
union all
select * from [CTE] p, [TheTable] c where c.[ParentId] = p.[NodeId]
and c.[ParentId] <> c.[NodeId]
)
select * from [CTE]