Hello everyone!
Great post!
The only way I've found to get the manager name is changing the table "_hirearchy b" for @Employees in the final select with a left join. It also works with the original insert for the ID 1 with Reports_To_ID = NULL.
I guess this decrease performance or, at least, you lose some of the advantages of using CTE.
FROM _hirearchy a LEFT OUTER JOIN @Employees b ON b.Employee_ID = a.Reports_To_ID
Please, tell me if this is too awful :-P.
Greetings to all!