SQL Flow Field Guide

hierarchyid.IsDescendantOf

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

tree predicate IsDescendantOf

What changes

Input
two hierarchyid values
Output or change
bit
Return type
SQL Server return type:bit CLR return type:SqlBoolean

Syntax at a glance

child. IsDescendantOf ( parent )

Work example

Filter nodes that belong to a selected parent subtree.

Pass the ancestor path and test whether the ancestor itself should remain in the result.

Check your work IsDescendantOf returns true for the same node as well as for its descendants.

Practice SQL

Open in SQL Flow
DECLARE @parent hierarchyid = hierarchyid::Parse('/4/'); DECLARE @node hierarchyid = hierarchyid::Parse('/4/2/'); SELECT @node.IsDescendantOf(@parent) AS in_subtree;

Open Microsoft Learn for full syntax, permissions, and details for your version.