O'Reilly logo

Foundations of SQL Server 2008 R2 Business Intelligence, Second Edition by Guy Fouché, Lynn Langit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying Hierarchical Data in SSMS

You can view hierarchical data via SSMS. To view a textual representation of the EmployeeHierarchy table, enter and execute the following code:

Select Name, Position, OrganizationLevel.ToString() From EmployeeHierarchy;

This will list each employee, along with his or her position and a text representation of that person's location in the hierarchy. The ToString method returns your HierarchyID, using a single slash character (/) to represent the root node. Looking at Bob and Andy, you can see that they are siblings and children of Kay. Figure A-2 shows the results of the preceding query in SSMS. The third column shows each person's location in the hierarchy. The delimited string that you see is termed a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required