CTE to traverse back up a hierarchy?
问题 I can find all the children of a given record in a hierarchical data model (see code below) but I'm not sure how to traverse back up the Parent/Child chain with a given Child ID. Can anyone point me in the right direction to figure out how to do this? Is this possible in Linq to SQL as well? WITH TaskHierarchy (TaskID, [Subject], ParentID, HierarchyLevel, HierarchyPath) AS ( -- Base case SELECT TaskID, [Subject], ParentID, 1 as HierarchyLevel, CONVERT(VARCHAR(MAX),'/') AS HierarchyPath FROM