Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)

  • RE: To get employee hierarchy

    One more try -

    WITH DirectReports AS

    (

    SELECT

    e.ManagerID

    ,e.EmployeeID

    ,e.Title

    ,0 AS LEVEL

    ,cast(e.ManagerID AS varchar(MAX)) AS [path]

    FROM dbo.MyEmployees AS e

    WHERE ManagerID IS NULL

    UNION ALL

    SELECT

    e.ManagerID

    ,e.EmployeeID

    ,e.Title

    ,LEVEL + 1

    ,cast(cast(e.ManagerID...

  • RE: To get employee hierarchy

    If I understand the question - this should get you a path - you may want to modify the ordering etc.

    WITH DirectReports AS

    (

    SELECT

    e.ManagerID

    ,e.EmployeeID

    ,e.Title

    ,0 AS LEVEL

    ,cast(e.ManagerID...

Viewing 2 posts - 1 through 2 (of 2 total)