with cte (empID,manID,depth,hierarchy) as
(
select e.employeeID,e.managerID ,1 , cast(e.employeeID as nvarchar(max))as hierarchy
from humanresources.Employee as e
where managerID is null
union all
select emp.employeeID,emp.managerID ,depth+1 , hierarchy + ‘/’ +cast(emp.employeeID as nvarchar(max)) as hierarchy
from humanresources.Employee emp
inner join cte
on emp.managerID=cte.empID
)
select * from cte order by depth
NOTE :
If you are in need of any Web Development feel free to Inquire us . Dhanashree Inc. Expertise in Asp.net Development, Php Development, Website designing, Open Source customisation. Dhanashree Inc can be our offshore development company / outsourcing web development company, hire dedicated web programmers.
Above information is for knowledge sharing if you have problem / issue / suggestion please intimate us with details for proper and prompt action.

