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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to loop through the record

Author  Topic 

imranabdulaziz
Yak Posting Veteran

83 Posts

Posted - 2008-01-28 : 23:36:27
Dear all,
I am using sql server 2005.
Actually I am trapped in one situation.
I have one table where I get employee level(emp_lvl)[level where employee working moves from 1 to 8 which comes from level_master ] , to whom he is reporting(emp_boss_code) ie his boss , and empcode and employee name .

I need to find out given employee code all his subordinates and their subordinates

Please suggest some idea to get desired outcome.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-29 : 01:33:52
you need to use recursive CTE for this. Refer to this link:-

[url]http://www.4guysfromrolla.com/webtech/071906-1.shtml[/url]
Go to Top of Page
   

- Advertisement -