hierarchyid.GetDescendant
tree navigation GetDescendant
What changes
- Input
- hierarchyid instance and arguments
- Output or change
- hierarchyid
- Return type
- SQL Server return type:hierarchyid CLR return type:SqlHierarchyId
Syntax at a glance
parent.GetDescendant ( child1 , child2 )
Work example
Choose a new child path between sibling positions when inserting into a hierarchy.
Pass the nearest lower and upper siblings, then persist the returned path with the new node.
Check your work GetDescendant returns a path between the supplied siblings when such an ordering is possible.
Practice SQL
Open in SQL FlowDECLARE @parent hierarchyid = hierarchyid::Parse('/4/'); SELECT @parent.GetDescendant(NULL, NULL).ToString() AS child_path;
Open Microsoft Learn for full syntax, permissions, and details for your version.