| title | GetRoot (Database Engine) | ||
|---|---|---|---|
| description | GetRoot (Database Engine) | ||
| author | MikeRayMSFT | ||
| ms.author | mikeray | ||
| ms.date | 07/22/2017 | ||
| ms.service | sql | ||
| ms.subservice | t-sql | ||
| ms.topic | reference | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]
Returns the root of the hierarchy tree. GetRoot() is a static method.
-- Transact-SQL syntax
hierarchyid::GetRoot ( )
-- CLR syntax
static SqlHierarchyId GetRoot ( )
[!INCLUDEsql-server-tsql-previous-offline-documentation]
SQL Server return type:hierarchyid
CLR return type:SqlHierarchyId
Used to determine the root node in a hierarchy tree.
The following example returns the root of the hierarchy tree:
SELECT OrgNode.ToString() AS Text_OrgNode, *
FROM HumanResources.EmployeeDemo
WHERE OrgNode = hierarchyid::GetRoot() The following code snippet calls the GetRoot() method:
SqlHierarchyId.GetRoot() hierarchyid Data Type Method Reference
Hierarchical Data (SQL Server)
hierarchyid (Transact-SQL)