July 2012
Intermediate to advanced
816 pages
27h 38m
English
Three more hierarchyid methods—Parse, Read, and Write—are provided by the hierarchyid data type, although they are less often used.
Parse is essentially the reverse of ToString. It accepts the same slash-delimited string representation that is returned by ToString and returns the equivalent compacted varbinary hierarchyid value that SQL Server uses internally to represent the nodes. This value could then be passed to ToString, in which case you’d get the original slash-delimited string back. It is the only other static method besides GetRoot, and so it uses the double-colon syntax, as follows:
SELECT hierarchyid::Parse('/2/1/1/') AS NodeId
GO
NodeId
----------
0x6AD6
(1 row(s) affected)Together, Parse and ToString enable ...
Read now
Unlock full access