Skip to content

Latest commit

 

History

History
69 lines (52 loc) · 1.72 KB

getroot-database-engine.md

File metadata and controls

69 lines (52 loc) · 1.72 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
GetRoot (Database Engine)
GetRoot (Database Engine)
MikeRayMSFT
mikeray
07/22/2017
sql
t-sql
reference
GetRoot
GetRoot_TSQL
GetRoot [Database Engine]
TSQL

GetRoot (Database Engine)

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]

Returns the root of the hierarchy tree. GetRoot() is a static method.

Syntax

-- Transact-SQL syntax  
hierarchyid::GetRoot ( )   
-- CLR syntax  
static SqlHierarchyId GetRoot ( )   

[!INCLUDEsql-server-tsql-previous-offline-documentation]

Return Types

SQL Server return type:hierarchyid

CLR return type:SqlHierarchyId

Remarks

Used to determine the root node in a hierarchy tree.

Examples

A. Transact-SQL example

The following example returns the root of the hierarchy tree:

SELECT OrgNode.ToString() AS Text_OrgNode, *  
FROM HumanResources.EmployeeDemo  
WHERE OrgNode = hierarchyid::GetRoot()  

B. CLR example

The following code snippet calls the GetRoot() method:

SqlHierarchyId.GetRoot()  

See also

hierarchyid Data Type Method Reference
Hierarchical Data (SQL Server)
hierarchyid (Transact-SQL)