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.
| Author |
Topic |
|
rc1138
Starting Member
35 Posts |
Posted - 2010-11-30 : 17:12:27
|
| Hi all,Was wondering if someone can assist me with a Employee Hierarchy problem.We currently have a table that only shows your direct managerTable structureID|NAME|MGR_ID1||Bob||22||Jeff||33||Carl||4The new table as per the requirements need to look like thisID|NAME|MGR1|MGR2|MGR31||Bob||2||3||42||Jeff||3||43||Carl||4And so onHaving a bit of difficulty trying to figure out the logic for outputting a table similar to that. Any Help/Ideas would be greatly appreciated |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2010-12-01 : 01:46:56
|
| create a seperate table for managers and employees.and then create seperate mapping table where you will be storing both employee id and manager id.now each employee id can have multiple manager id's.if iam not wrong |
 |
|
|
rc1138
Starting Member
35 Posts |
Posted - 2010-12-01 : 08:37:05
|
| Yes each employee can have multiple manager id's |
 |
|
|
rc1138
Starting Member
35 Posts |
Posted - 2010-12-01 : 08:39:44
|
| I see so create a table for employees and managers containing just their names and ID's ? |
 |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2010-12-01 : 11:20:16
|
| exactly...after creating the two table then create a mapping table as i said. |
 |
|
|
rc1138
Starting Member
35 Posts |
Posted - 2010-12-01 : 17:13:23
|
| I see thanks! |
 |
|
|
|
|
|