Fog Creek Software
Discussion Board




SQLServer Help

Hello all,
Greetings.
My problem is as follows
I have a table in the following format
Employees
=========
Emp_Id            Emp_Name  Boss_Id
1        A      0
2        B      1
3        C      2
4        D      2
5        E      4
6        DA      3
7        FA      5
8        G      6
9        H      7
10        I      1
11        J      8
12        K      5

Now I want to write a procedure which would return me all
the Boss_Ids until 0 level for a given Emp_Id. 
for eg: If I give EmpId as 11 then I want 11,8,6,3,2,1
How to achieve this in SqlServer2k/7.0
TIA
Prasad.

Prasad
Tuesday, April 22, 2003

Sounds like you gotta do trees. There's an Oracle way to do it but I remember right now.

Li-fan Chen
Wednesday, May 28, 2003

http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20146514.html

Li-fan Chen
Wednesday, May 28, 2003

*  Recent Topics

*  Fog Creek Home