Tough i am not happy with below solution but this could get you going.
DECLARE @TBL TABLE
(
PARENTID INT,
CHILDID INT
)
DECLARE @TAGERTTBL TABLE
(
PARENTID INT,
CHILDID INT,
Level int IDENTITY(0, 1)
)
INSERT INTO @TBL(PARENTID, CHILDID)
SELECT 1, 11 UNION ALL
SELECT 11, 21 UNION ALL
SELECT 21, 31 UNION ALL
SELECT 31, 41 UNION ALL
SELECT 41, 51 UNION ALL
SELECT 51, 61 UNION ALL
SELECT 61, 71;
with TMPH(ParentId, ChildID, Level)
AS (
SELECT ParentID, CHildID, 0 AS level
FROM @TBL
WHERE PARENTID = 61
UNION ALL
SELECT T.ParentId, T.ChildID, Level + 1
FROM TMPH TM
INNER JOIN @TBL T ON TM.ParentId = T.ChildID
)
INSERT INTO @TAGERTTBL(PARENTID, CHILDID)
SELECT PARENTID, CHILDID FROM TMPH
order by Level desc
SELECT *
FROM @TAGERTTBL
where Level in (2,3 )