Instantly share code, notes, and snippets.

Embed
What would you like to do?
USE AdventureWorks2012;
GO
with my_employee as (
select employeeid,firstname,lastname,title, cast('' as varchar) as manager
from dbo.MyEmployees
where managerId is null
union all
select a.employeeid,a.firstname,a.lastname,a.title, cast(b.firstname+' '+b.lastname+' '+b.title as varchar) as manager
from dbo.MyEmployees a inner join
my_employee b on a.managerid = b.employeeid
)
select * from my_employee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment