SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

sanjay5219
Posting Yak Master

219 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

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
Flowing Fount of Yak Knowledge

3573 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

sanjay5219
Posting Yak Master

219 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  
 New 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.06 seconds. Powered By: Snitz Forums 2000