In my table each record has a pointer to his direct parent and I need to know how to query for all the descendants, direct or not (the son of a son), of a given record.
Facts:
- I don’t know how deep the tree is and i need all the leafs
- Some records might not have a child record
- I’m running under SqlServer 2012
Can anyone tell me how to write such a query?
Building on the query from Josh Wallace, to get descendents.