Recursive Select Statements

  • Hi all, new to the forum and using SQL Server 2000. I have a table of employees, each employee has an employeeid and a supervisorid. What I want to do is select every employee that rolls up to a top manager, so if say an employees manager's manager's manager is the VP, that employee would be selected. Is there any way to do this easily? I know oracle has the connect by clause but havent found anything comparable in sqlserver. thanks

  • Create table function dbo.Managers(EmployeeId) to return list of all managers of the Employee (you may add column "level" to retyurned recordset) and then join this function to employee table.

    _____________
    Code for TallyGenerator

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply