Debe usar una expresión de tabla común recursiva, luego filtrar los resultados solo por la ruta base para cada registro (es decir, para ID 1131 obtenga ABC/RST/UVW
y no solo ABC/RST
WITH CTE AS
( SELECT ID,
Name,
ParentID,
NextParentID = ParentID,
Path = CAST(Name AS VARCHAR(MAX)),
Recursion = 1
FROM T
UNION ALL
SELECT CTE.ID,
CTE.Name,
CTE.ParentID,
T.ParentID,
CAST(T.Name + '/' + CTE.Path AS VARCHAR(MAX)),
Recursion + 1
FROM CTE
INNER JOIN T
ON CTE.NextParentID = T.ID
), CTE2 AS
( SELECT CTE.ID,
CTE.Name,
CTE.ParentID,
CTE.Path,
RowNumber = ROW_NUMBER() OVER(PARTITION BY CTE.ID ORDER BY Recursion DESC)
FROM CTE
)
SELECT ID, Name, ParentID, Path
FROM CTE2
WHERE RowNumber = 1;