Skip to content

Latest commit

 

History

History
69 lines (54 loc) · 1.71 KB

File metadata and controls

69 lines (54 loc) · 1.71 KB
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
GetRoot
GetRoot_TSQL
dev_langs
TSQL
helpviewer_keywords
GetRoot [Database Engine]
ms.assetid 240b70f1-eeda-44ab-b4bb-9e4af80fa7c0
author MikeRayMSFT
ms.author mikeray

GetRoot (Database Engine)

[!INCLUDEtsql-appliesto-ss2008-asdb-xxxx-xxx-md]

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

Syntax

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

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)