rocky_498 - Saturday, April 22, 2017 2:03 PM
While loops/cursors should be your very last resort for this type of problem - I'm absolutely sure that there is a set-based solution for you.
You say that you have two rows which remain unlinked.
1. Have you checked that there are matching rows available in the source table?
2. Assuming that matching rows are available for these two rows in the target table, have you checked to see whether or not they are all used up on previous rows in the target table?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden