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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Build Hierarchy
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

240 Posts

Posted - 09/03/2013 :  09:47:20  Show Profile  Reply with Quote
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


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


James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 09/03/2013 :  10:41:36  Show Profile  Reply with Quote
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

Posting Yak Master

240 Posts

Posted - 09/03/2013 :  17:48:26  Show Profile  Reply with Quote
Yes I am looking something recursive scheme
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000