with CTE_List as ( select * from YourTable t where t.StaffId = @M1 union all select * from CTE_List p, YourTable t where t.LevelId = p.StaffId ) select * from CTE_List
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)