SQL Flow Field Guide

hierarchyid::GetRoot

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

static GetRoot (hierarchyid::GetRoot)

What changes

Input
none or string path
Output or change
hierarchyid
Return type
SQL Server return type:hierarchyid CLR return type:SqlHierarchyId

Syntax at a glance

hierarchyid::GetRoot ( )

Work example

Use the canonical root path when building or comparing a hierarchy value.

Keep the root value as hierarchyid and compare paths with hierarchy methods.

Check your work GetRoot returns the hierarchyid root value represented by slash.

Practice SQL

Open in SQL Flow
SELECT hierarchyid::GetRoot().ToString() AS root_path;

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