| title | GetRoot (Database Engine) | Microsoft Docs | ||
|---|---|---|---|
| ms.custom | |||
| ms.date | 07/22/2017 | ||
| ms.prod | sql | ||
| ms.prod_service | database-engine, sql-database | ||
| ms.reviewer | |||
| ms.technology | t-sql | ||
| ms.topic | language-reference | ||
| f1_keywords |
|
||
| dev_langs |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | 240b70f1-eeda-44ab-b4bb-9e4af80fa7c0 | ||
| author | MikeRayMSFT | ||
| ms.author | mikeray |
[!INCLUDEtsql-appliesto-ss2008-asdb-xxxx-xxx-md]
Returns the root of the hierarchy tree. GetRoot() is a static method.
-- Transact-SQL syntax
hierarchyid::GetRoot ( ) -- CLR syntax
static SqlHierarchyId GetRoot ( ) 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)