Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

GetRoot (Database Engine)

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

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

SQL Server return type: hierarchyid

CLR return type: SqlHierarchyId

Used to determine the root node in a hierarchy tree.

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()
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.