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

SqlHierarchyId.ToString Method

Returns the canonical string representation of a SqlHierarchyId node from a SqlHierarchyId value.

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

[SqlMethodAttribute(DataAccess = DataAccessKind.None, SystemDataAccess = SystemDataAccessKind.None, 
	InvokeIfReceiverIsNull = false, OnNullCall = false, 
	IsDeterministic = true, IsPrecise = true, IsMutator = false)]
public override string ToString()

Return Value

Type: String
String

Called implicitly when a conversion from a SqlHierarchyId data type to a string type occurs.

Acts as the opposite of Parse.

DECLARE @StringValue AS nvarchar(4000), @hierarchyidValue AS hierarchyid
SET @StringValue = '/1/1/3/'
SET @hierarchyidValue = 0x5ADE

SELECT hierarchyid::Parse(@StringValue) AS hierarchyidRepresentation,
 @hierarchyidValue.ToString() AS StringRepresentation ;
GO

Community Additions

ADD
Show:
© 2015 Microsoft