troubleshooting Question

How do I recurse up a multi-level Parent-Child relationship in T-SQL?

Avatar of edenmachine
edenmachine asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Editors IDEs
8 Comments4 Solutions2020 ViewsLast Modified:
I have a db table with multilevel parent-child relationships (it populates a treeview)

I want to be able to take any given ChildID and climb up the relationship in T-SQL creating a recordset of each of them until it hits the very top level

TaskID int unique
Subject varchar
ParentID int
Join our community to see this answer!
Unlock 4 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros