hierarchyid::GetRoot
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 FlowSELECT hierarchyid::GetRoot().ToString() AS root_path;
Open Microsoft Learn for full syntax, permissions, and details for your version.