-
Recusrive SQL help
Hi,
I have a table that has coms like below:
ManagerID INT
EmployeeID INT
EmployeeName Varchar
EmployeeEmail Varchar
Now I have to create a stored proc to which I pass one Emp ID and it should get me all employee udenr him till last employee in the hierarchy.
So if one manager has three sub managers and two employee and those three manager has 2 employees each, and if I pass the emp ID of the main manager, it should give me All EmpID under him and also under the sub mangers he has. And If I pass one of the sub managers, it should give me the EmpID of only those two who are under him.
I hope I am making sens.
I created a SP that uses a cursor and recursively calls itself. But it is not working as expected. I so not think I should use cursor here in the first place. Please help.
Regards,
Sandy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|