Get this table in SQL Server 2005, which is used to maintain a history of merge operations:
- Column FROM_ID (int)
- Column TO_ID (int)
Now I need a query that takes the original FROM_ID as input and returns the last available TO_ID.
So for example:
- ID 1 is combined with ID 2
- Later, ID 2 is combined into ID 3
- Again later ID 3 combines into ID 4
So the query I'm trying to collect will take ID 1 as input (in the WHERE clause I assume), and should give me the last available TO_ID, in this case 4.
I guess I need recursive logic, but don't know how to get started.
Thank!
Mathieu