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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 how to write a query or a stored proc...?

Author  Topic 

saikrishnat
Starting Member

1 Post

Posted - 2005-01-14 : 12:46:02
Hello,

my table contains 2 columns .

EmpID varchar(10),ReportingToID varchar(10)

how to write a query that returns all the employees under a ReportingToID ...?

the key here is i want all the employees that are under a ReportingToID tree.

i don't know the exact number of levels under a ReportingToID

empID ManagerID

abc ""

def abc

ghi abc

jkl ghi

klk jkl

mmm jkl



Thank You

Sai

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2005-01-14 : 13:49:08
Have a look at the following article - Robvolk has done a nice presentation on this topic of trees.

http://www.sqlteam.com/item.asp?ItemID=8866
Go to Top of Page
   

- Advertisement -