I have two tables:
Folder, Files.
Each table has 4 fields:
ParentID, ID, Name, Type
I need to create a CTE in order to retrieve the entire tree in one shot, using T-SQL.
So far this is what I have done, but the recursion is not active yet.
I forgot to mention that inside a folder there may be one or more folders/files.
Assuming that you’re using
NULLfor theParentIDitems in the root the following should work: