WITH TEST_CTEAS(SELECT id,position,Parentid,Cast(Parentid AS NVARCHAR(4000)) AS PATHFROM op_client_sales_structure teamWHERE Parentid !=-1UNION ALLSELECT a.id,a.position,a.Parentid,CTE.PATH+','+Cast(a.Parentid AS NVARCHAR(4000)) AS PATHFROM op_client…