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

Adding Data to the Table

Next, you will add five employees to the EmployeeHierarchy table. The employees (and their positions within the company) will be named Jodi (CEO), Jim (CFO), Kay (COO), Bob (Manager), and Andy (Manager). To accomplish this, enter and execute the following code:

Declare @CEO HierarchyID,   @COO HierarchyID,   @CLevel HierarchyID; Select  @CEO = HierarchyID::GetRoot(); Insert Into dbo.EmployeeHierarchy (Name, Position, OrganizationLevel) Values ('Jodi','CEO', @CEO),   ('Jim','CFO', @CEO.GetDescendant(Null,Null)); Select @CLevel =MAX(OrganizationLevel) From dbo.EmployeeHierarchy Where OrganizationLevel.GetAncestor(1)= @CEO; Insert Into dbo.EmployeeHierarchy (Name, Position, OrganizationLevel) Values ('Kay','COO', ...

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