I have this table in SQL Server:
Parent   Child
   1        2 
   89       7 
   2        3 
   10       5 
   3        4
I need to build a recursive Stored Procedure that finds the maximum ascendant of any child.
For example: If I want to find the maximum ascendant of 4, it should return 1 because:
4 is the child of 3.
3 is the child of 2.
2 is the child of 1.
So I can find the ultimate parent.
 
     
    