Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Build Hierarchy

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2013-09-03 : 09:47:20
Hi All,
I have one table Emp_MAster with two column ID-Sup_Id. I need to create a table where i can store data link this

Id-Hreid

Only diffrence is that I need to store data in an hierarchy view so Emp 1 is reporting to Emp2 and Emp2 is reportign to Emp3 so in new table I should get

Emp3-Emp2
Emp3-Emp1
Emp2-Emp1

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-03 : 10:41:36
What do you want to see if you had more than one layer of management - for example, your data was like this:

Id Sup_id
1 2
2 3
3 4
Are you looking for the ultimate supervisor, or all the links in between? If it is the ultimate supervisor only, I guess it would be simple enough - just add the CEO or whomever is the big boss as the Hreid along with every employee's id as Id. If you are looking for all links, you will need to use a recursive scheme.
Go to Top of Page

sanjay5219
Posting Yak Master

240 Posts

Posted - 2013-09-03 : 17:48:26
Yes I am looking something recursive scheme
Go to Top of Page
   

- Advertisement -