July 5, 2008 at 10:18 am
I am struggling to display the results recursively.
My scenario is :
Table Name: Organization
Column Name: Managers
Column Name: Subordinates
The Organization table structure is like:
Managers Subordinates
Frank - Tim
Frank - Jacob
Frank - John
Frank - Mark
John - Randy
John - Dave
Dave - Tom
Dave - Jen
Mark - Joey
Mark - Steven
Now, when I will search for "Dave" then I should get the results for all the guys who report to him as well as all the managers whom "Dave" reports to. (Tree hive for Dave’s managers will be: Dave – John - Frank). So indirectly “Dave” reports to “Frank”.
So output for Dave will be (subordinates and his managers):
Tom
Jen
John
Frank
Can anybody please help me out?
Thanks,
Neel
July 5, 2008 at 10:29 am
are you running SQL 2005?
If so, you can use RECURSIVE CTE.
The very same example is shown all over google, as well as MSDN.
Look for it.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply