We have 800 people or so in our Org.
I would like to be able to pass the VP managers ID number (Enterprise ID), have it get all four of his “Reports to” Managers. Lets call them Report1.
Then loop through the Report1 Enterprise ID to find their Report2 people, and so on.
So we end up with a hierarchy of employees.
Each Row or Employee has both their own Enterprise ID and their managers Enterprise ID.
Is there a way to do this in T-SQL. someone did it in .NET but I was told if it was done in SQL it would run way faster. There are over 200,000 people in the entire list so it can take a while.
If a manager has one or more people under them we need to get them all.
So if the VP Enterprise ID = 1234
Then his reports to would each have their managers ID = 1234
example
txtGivenName txtEnterpriseID txtManagerEnterpriseID
VP 1234 we don’t care
sue 8737 1234
kim 8723 1234
bob 8675 1234
joe 6544 1234
cary 8777 6544
dave 8737 6544
fred 7664 8675
mary 9009 8723
an so on for 800 people...
gmmastros helped me with this code in another post. which gets the VP.
how can I store each of the txtManagerEnterpriseID in ana array to get their Reports to. then store thsoes in an array to get their Reports to, etc.
Hope this makes sense
TIA
DougP
I would like to be able to pass the VP managers ID number (Enterprise ID), have it get all four of his “Reports to” Managers. Lets call them Report1.
Then loop through the Report1 Enterprise ID to find their Report2 people, and so on.
So we end up with a hierarchy of employees.
Each Row or Employee has both their own Enterprise ID and their managers Enterprise ID.
Is there a way to do this in T-SQL. someone did it in .NET but I was told if it was done in SQL it would run way faster. There are over 200,000 people in the entire list so it can take a while.
If a manager has one or more people under them we need to get them all.
So if the VP Enterprise ID = 1234
Then his reports to would each have their managers ID = 1234
example
txtGivenName txtEnterpriseID txtManagerEnterpriseID
VP 1234 we don’t care
sue 8737 1234
kim 8723 1234
bob 8675 1234
joe 6544 1234
cary 8777 6544
dave 8737 6544
fred 7664 8675
mary 9009 8723
an so on for 800 people...
gmmastros helped me with this code in another post. which gets the VP.
how can I store each of the txtManagerEnterpriseID in ana array to get their Reports to. then store thsoes in an array to get their Reports to, etc.
Code:
Select Employee.txtEnterpriseID ,
Employee.txtSurName + ', ' + Employee.txtGivenName as 'Name' ,
Employee.txtInternalEmail ,
Employee.txtManagerEnterpriseID ,
Manager.txtSurName + ', ' + Manager.txtGivenName as 'Manager Name',
TIA
DougP