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 |
jubinjose
Starting Member
20 Posts |
Posted - 2008-03-17 : 03:50:14
|
My table structure is - employee_id employee_name manager_idmanager_id will point to another record in the same table because ultimately manager is also an employee. CEO doesn't report to anyone and hence his manager_id is nullSample dataemployee_id, employee_name, manager_id, 1 John 33 Jim 22 Tom 55 Alex nullNow I want to be able to accept an employee_id as parameter and output his reporting hierarchy. So if my input parameter is 1, my output should beAlex\Tom\Jim\JohnWhat is an elegant query to get this result? |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-03-17 : 05:40:01
|
Read about Expanding Hierarchies in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|