April 2011
Beginner to intermediate
443 pages
11h
English
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', ...Read now
Unlock full access