Skip to content

Latest commit

 

History

History
77 lines (62 loc) · 1.9 KB

File metadata and controls

77 lines (62 loc) · 1.9 KB
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
database-engine
ms.tgt_pltfrm
ms.topic language-reference
f1_keywords
GetRoot
GetRoot_TSQL
dev_langs
TSQL
helpviewer_keywords
GetRoot [Database Engine]
ms.assetid 240b70f1-eeda-44ab-b4bb-9e4af80fa7c0
caps.latest.revision 17
author edmacauley
ms.author edmaca
manager craigg
ms.workload Inactive

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)