Recursive CTE

hi

hope this helps

please see this thread

Get source values for specific target value - Transact-SQL - SQLTeam.com Forums