title: Sql query to get organisational level hierarchy from one table
body: <p>I have one table named employee. Please refer to given below table and i want the level in which employee reporting to which manager. I dont know what will be the logic. I have used CTE but I am not getting the expected result.Please help me out in this case for getting the expected result.</p>
  
  <p>Table Employee</p>
  
  <pre><code>EmpID.                     EmpName.                         ManagerID
  1                             A                                Null
  2                             B                                  1
  3                             C                                  1
  4                             D                                  2
  5                             E                                  3
  6                             F                                  4
  7                             G                                  5
  8                             H                                  5
  </code></pre>
  
  <p>Expected Result</p>
  
  <pre><code>EmpName.                      ManagerName                         Level
  A                                Null                                1
  B                                  A                                 2
  C                                  A                                 2
  D                                  B                                 3
  E                                  C                                 4
  F                                  D                                 5
  G                                  E                                 6
  H                                  E                                 6
  </code></pre>