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 |
|
|
|
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]
Returns the root of the hierarchy tree. GetRoot() is a static method.
-- Transact-SQL syntax
hierarchyid::GetRoot ( )
-- CLR syntax
static SqlHierarchyId GetRoot ( )
[!INCLUDEsql-server-tsql-previous-offline-documentation]
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)