O'Reilly logo

Programming Microsoft® SQL Server™ 2008 by Leonard Lobel, Andrew Brust, and Stephen Forte

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

Populating the Hierarchy

Let’s visualize our organizational chart before we start populating the Employee table with hierarchical data. Figure 7-1 shows the hierarchy of employees in our organization.

Hierarchical organizational chart

Figure 7-1. Hierarchical organizational chart

The first row added to a hierarchical table is always the root node of the tree, and there can be only one root. Additional rows beneath the root are then added as child and grandchild nodes, and so on. Nodes can be rearranged as needed by invoking methods on the hierarchyid values. The tree can grow both broad (with many siblings) and deep (with many descendants).

The GetRoot Method

We begin by inserting our ...

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