SQL Flow Field Guide

hierarchyid data type

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

hierarchyid CLR data type (tree position)

What changes

Input
none
Output or change
none

Syntax at a glance

column_name hierarchyid | DECLARE @h hierarchyid

Work example

Represent a node's position in a tree when hierarchy queries and ordered subtree ranges fit the data model.

Store a stable business key beside the hierarchy path and define how inserts and moves update descendants.

Check your work hierarchyid encodes a path and does not create parent rows, enforce a foreign key, or cascade a move by itself.

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