I want to select the step count of this query (which one is do fiirst and continue + 1) from query below
;WITH EmpCTE( BomID , empid, mgrid,BomMgrId, lvl, Qty , FLG)
AS
(
SELECT BomID , empid , mgrid, 0 as BomMgrId , 0, Qty , FLG
FROM Employees
WHERE empid = 1
UNION ALL
SELECT E.BomID , E.empid, E.MgrId, M.BomID as BomMgrId , M.lvl+1 , E.Qty , E.FLG
FROM Employees AS E
JOIN EmpCTE AS M
ON E.mgrid = M.empid
)
SELECT BomID , empid, BomMgrId as mgrid , FLG , qty , lvl FROM EmpCTE WHERE FLG is null