with temp ( [Id], [parentid])
as
(
select Id, parentid
from DiGui
where [parentid] = 15
union all
select a.Id, a.parentid
from DiGui a
inner join temp on a.[parentid] = temp.[Id]
)
select * from temp
with temp ( [Id], [parentid])
as
(
select Id, parentid
from DiGui
where [parentid] = 15
union all
select a.Id, a.parentid
from DiGui a
inner join temp on a.[parentid] = temp.[Id]
)
select * from temp