Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

GetRoot (Database Engine)


Applies To: SQL Server 2014, SQL Server 2016 Preview

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

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.

-- 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.

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:

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft