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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Get employeeName

Author  Topic 

basicconfiguration
Constraint Violating Yak Guru

358 Posts

Posted - 2010-02-12 : 14:43:24
Table1 has 3 col.
empid, empname, manager
1,'xxx', JOHN
2,'fff', MICHAEL
3,'uuu', SAM


How could I get direct and indirect empname that are under managerJOHN?

results:
xxx, JOHN
fff, JOHN
uuu, JOHN

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-02-12 : 15:24:05
Data doesn't show that...how do you say JOHN is the manager of fff and uuu...they have their own managers according to the sample data.
Go to Top of Page

basicconfiguration
Constraint Violating Yak Guru

358 Posts

Posted - 2010-02-12 : 18:53:09
But i wanna get them all just like the result or I can't?
Go to Top of Page

basicconfiguration
Constraint Violating Yak Guru

358 Posts

Posted - 2010-02-13 : 04:03:32
Never mind the question that I asked is wrong. The question it is to get the number of direct and indirect employees whom are under the managers. I was reading in BOL about common table expressions and I found the answer in one of the examples.
Go to Top of Page
   

- Advertisement -