Skip to content

Latest commit

 

History

History
69 lines (52 loc) · 1.72 KB

File metadata and controls

69 lines (52 loc) · 1.72 KB
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
GetRoot
GetRoot_TSQL
helpviewer_keywords
GetRoot [Database Engine]
dev_langs
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)