title: Finding a Top Level Parent in SQL
body: <p>I have got two tables as following</p>
  <p>Table <code>Person</code></p>
  <pre><code>  Id   Name
     1    A
     2    B
     3    C
     4    D
     5    E
  </code></pre>
  <p>Table <code>RelationHierarchy</code></p>
  <pre><code>ParentId   ChildId
     2         1
     3         2
     4         3
  </code></pre>
  <p>This will form a tree like structure</p>
  <pre><code>          D
            |
            C
            |
            B
            |
            A
  </code></pre>
  <p>ParentId and ChildId are foreign keys of Id column of Person Table</p>
  <p>I need to write SQL that Can fetch me Top Level Parent i-e Root. Can anyone suggest any SQL that can help me accomplish this</p>