I am trying to write a stored procedure that could create a table called tblManagerHiera rchy. It is a table that contains recursive data.
The data is coming from tblEmployee where it contains that EmpNum and ManagerEmpNum.
tblEmployee (EmpNum, ManagerEmpNum)
The tblManagerHiera rchy should contain Manager's EmpNum plus direct and indirect subordinates' EmpNum.
Basically it should contain everybody who reports to a Manager directly and indirectly. So CEO should contain everyone in the company, and general manager only has few..
The table's structure should be like this.
tblManagerHiera rchy (ManagerEmpNum, EmpNum)
I need to use store procedure that contains cursor and loop.
Any sample of code is appreciated.
Thanks.
The data is coming from tblEmployee where it contains that EmpNum and ManagerEmpNum.
tblEmployee (EmpNum, ManagerEmpNum)
The tblManagerHiera rchy should contain Manager's EmpNum plus direct and indirect subordinates' EmpNum.
Basically it should contain everybody who reports to a Manager directly and indirectly. So CEO should contain everyone in the company, and general manager only has few..
The table's structure should be like this.
tblManagerHiera rchy (ManagerEmpNum, EmpNum)
I need to use store procedure that contains cursor and loop.
Any sample of code is appreciated.
Thanks.
Comment