Possible Duplicate:
Recursive function in sql server 2005?
How do you perform an iterative query on a table? I have a simple table which consists of a:
KeyField, childID, parentID
Starting with a childID, I want to pull the parentID and then query again to see if that parent (which is now the child) has its own parent, working up through the complete hierarchy, how do I do that?
Microsoft SQL Server, version number 09.00.3042