Recursive CTE-Find all Employees Below Manager
问题 I created a sample fiddle for this SQLFIDDLE CREATE TABLE [dbo].[Users]( [userId] [int] , [userName] [varchar](50) , [managerId] [int] , ) INSERT INTO dbo.Users ([userId], [userName], [managerId]) VALUES (1,'Darry',NULL), (2,'Cono',1), (3,'Abros',2), (4,'Natesh',1), (5,'Ani',3), (6,'Raju',5), (7,'Pinky',5), (8,'Miya',4) My requirement is like displaying all employees hierarchy below that particular manager Here is what i tried WITH UserCTE AS ( SELECT userId, userName, managerId, 0 AS