sql >> Base de Datos >  >> RDS >> Sqlserver

La consulta recursiva de SQL solo devuelve la última fila

with recury as (
Select 
fs1.ID ,fs1.FParent,fs1.FName 
from  FoldersStructure as  fs1
where fs1.ID=8

union all
select fs2.id,fs2.FParent,fs2.FName 
from FoldersStructure as  fs2
inner join recury as r on fs2.ID= r.FParent

)
select ID,FParent,FName
from recury 
order by ID 

SQL-Fiddle