| title | GetRoot (Database Engine) | Microsoft Docs | ||
|---|---|---|---|
| ms.custom | |||
| ms.date | 7/22/2017 | ||
| ms.prod | sql-non-specified | ||
| ms.prod_service | database-engine, sql-database | ||
| ms.service | |||
| ms.component | t-sql|data-types | ||
| ms.reviewer | |||
| ms.suite | sql | ||
| ms.technology |
|
||
| ms.tgt_pltfrm | |||
| ms.topic | language-reference | ||
| f1_keywords |
|
||
| dev_langs |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | 240b70f1-eeda-44ab-b4bb-9e4af80fa7c0 | ||
| caps.latest.revision | 17 | ||
| author | edmacauley | ||
| ms.author | edmaca | ||
| manager | craigg | ||
| ms.workload | Inactive |
[!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)