Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

La requête récursive SQL ne renvoie que la dernière ligne

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