Querying the Hierarchy

Now that you’ve populated the hierarchy, you should query it to view the data and verify the hierarchy was populated correctly. However, If you query the hid value directly, you see only its binary representation, which is not very meaningful. To view the Hierarchyid value in a more useful manner, you can use the ToString method, which returns a logical string representation of the Hierarchyid. This string representation is shown as a path with a slash sign used as a separator between the levels. For example, you can run the following query to get both the binary and logical representations of the hid value:

image

As stated previously, ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.