Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

SqlHierarchyId Structure

 

Applies To: SQL Server 2016 Preview

The SqlHierarchyId type represents a position in a hierarchical structure, specifying depth and breadth.

Namespace:   Microsoft.SqlServer.Types
Assembly:  Microsoft.SqlServer.Types (in Microsoft.SqlServer.Types.dll)

[SqlUserDefinedTypeAttribute(Format.UserDefined, IsByteOrdered = true, 
	MaxByteSize = 892, Name = "SqlHierarchyId")]
[CLSCompliantAttribute(true)]
public struct SqlHierarchyId : IBinarySerialize, INullable, IComparable

NameDescription
System_CAPS_pubpropertyIsNull

Gets a value indicating whether the SqlHierarchyId is null.

System_CAPS_pubpropertySystem_CAPS_staticNull

Gets a SqlHierarchyId with a hierarchy identification of null.

NameDescription
System_CAPS_pubmethodCompareTo(Object)

Returns a value indicating the results of a comparison between a SqlHierarchyId and an object.

System_CAPS_pubmethodCompareTo(SqlHierarchyId)

Returns a value indicating the results of a comparison between two SqlHierarchyId nodes.

System_CAPS_pubmethodEquals(Object)

Evaluates whether SqlHierarchyId and obj are equal.(Overrides ValueType.Equals(Object).)

System_CAPS_pubmethodGetAncestor(Int32)

Retrieves the SqlHierarchyId node n levels up the hierarchical tree.

System_CAPS_pubmethodGetDescendant(SqlHierarchyId, SqlHierarchyId)

Gets the value of a descendant SqlHierarchyId node that is greater than child1 and less than child2.

System_CAPS_pubmethodGetHashCode()

Gets a hash of the path from the root node of the hierarchy tree to the SqlHierarchyId node.(Overrides ValueType.GetHashCode().)

System_CAPS_pubmethodGetLevel()

Gets a value indicating the level of the SqlHierarchyId node in the hierarchical tree.

System_CAPS_pubmethodGetReparentedValue(SqlHierarchyId, SqlHierarchyId)

Gets a value representing the location of a new SqlHierarchyId node that has a path from newRoot equal to the path from oldRoot to this, effectively moving this to the new location.

System_CAPS_pubmethodSystem_CAPS_staticGetRoot()

Gets a value representing the root SqlHierarchyId node of the hierarchy.

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIsDescendantOf(SqlHierarchyId)

Gets a value indicating whether the SqlHierarchyId node is the descendant of the parent.

System_CAPS_pubmethodSystem_CAPS_staticParse(SqlString)

Converts the canonical string representation of a SqlHierarchyId node to a SqlHierarchyId value.

System_CAPS_pubmethodRead(BinaryReader)

Reads from a specified binary reader into a SqlHierarchyId.

System_CAPS_pubmethodToString()

Returns the canonical string representation of a SqlHierarchyId node from a SqlHierarchyId value.(Overrides ValueType.ToString().)

System_CAPS_pubmethodWrite(BinaryWriter)

Writes a SqlHierarchyId to a specified binary writer.

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticEquality(SqlHierarchyId, SqlHierarchyId)

Evaluates whether two SqlHierarchyId nodes are equal.

System_CAPS_puboperatorSystem_CAPS_staticGreaterThan(SqlHierarchyId, SqlHierarchyId)

Evaluates whether one specified SqlHierarchyId node is greater than another.

System_CAPS_puboperatorSystem_CAPS_staticGreaterThanOrEqual(SqlHierarchyId, SqlHierarchyId)

Evaluates whether one specified SqlHierarchyId node is greater than or equal to another.

System_CAPS_puboperatorSystem_CAPS_staticInequality(SqlHierarchyId, SqlHierarchyId)

Evaluates whether two SqlHierarchyId nodes are unequal.

System_CAPS_puboperatorSystem_CAPS_staticLessThan(SqlHierarchyId, SqlHierarchyId)

Evaluates whether one specified SqlHierarchyId node is less than another.

System_CAPS_puboperatorSystem_CAPS_staticLessThanOrEqual(SqlHierarchyId, SqlHierarchyId)

Evaluates whether one specified SqlHierarchyId node is less than or equal to another.

This type provides the following benefits for storing hierarchical information:

  • Very compact data storage.

  • Depth-first comparison. Indexes on this type are in depth-first order, and nodes close to each other in a depth-first traversal are stored near each other.

  • Support for arbitrary insertions and deletions.

  • A limitation of this type is that a single instance of the hierarchy data type can be no larger than 892 bytes. Hierarchies that possess too many levels to fit within this limitation must use a different data type.

The HierarchyId type is available to CLR clients as the SqlHierarchyId data type.

Legacy Code Example

DECLARE @employee hierarchyid
SELECT @employee = OrgNode FROM HumanResources.EmployeeDemo
  WHERE LoginID = 'adventure-works\dylan0'

SELECT * FROM HumanResources.EmployeeDemo
WHERE @employee.IsDescendantOf(OrgNode) = 1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top

Community Additions

Show:
© 2015 Microsoft