I have a table in SQL that links to itself through parentID. I want to find the children and their children and so forth until I find all the child objects. I have a recursive function that does this but it seems very ineffective.
Is there a way to get sql to find all child objects? If so how?
Using: Microsoft SQL Server Management Studio Express 9.00.2047.00
Have a look at using Sql Server 2005 CTEs.
Depending on the depth of the tree, you might want to take a look at
MAXRECURSION query hint