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.
Author |
Topic |
josephmp
Starting Member
3 Posts |
Posted - 2008-06-09 : 07:55:13
|
I have a table with EmployCode(int), EmployName(varchar) and SeniorCode(int). The table maintains a tree like hierarchy with top most member having a senior code as 0 and all other members will have a valid EmployCode as the Senior Code. I want to display all the employs that comes above the given employ in the tree structue upto the top most member who have the senior code as 0. If i input an employ code it should return all the seniors of this employ present in the hierarchy. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-09 : 08:32:14
|
Search for expanding hierarchies in books online |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-09 : 08:34:52
|
Refer this too:-http://www.sqljunkies.ddj.com/Article/D7CAED46-CCAC-4FF7-B528-B2E9A274B71C.scuk |
 |
|
josephmp
Starting Member
3 Posts |
Posted - 2008-06-09 : 09:20:47
|
Can i find the result without using the while loop. A recursive select statement or so. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-09 : 14:24:30
|
quote: Originally posted by josephmp Can i find the result without using the while loop. A recursive select statement or so.
You could do it with recursive CTE if you were using SQL 2005 or higher. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-09 : 15:29:00
|
quote: Originally posted by josephmp Can i find the result without using the while loop. A recursive select statement or so.
Why? I think in SQL Server 2000 it is not possible without using while loopMadhivananFailing to plan is Planning to fail |
 |
|
josephmp
Starting Member
3 Posts |
Posted - 2008-06-10 : 05:10:08
|
I have around 20000+ employees and I need to find the list of users senior to each of these users so as to split some amount between them. This operation has to be done often and the user hierarchy may vary each time. I need a method to generate this list with less time. Can u suggest a method in SQL 2000; also can you please tell me how to solve this in SQL 2005. |
 |
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
|
|
|
|