SQL Flow Field Guide

hierarchyid.GetDescendant

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

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 Flow
DECLARE @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.