I would like to add the unique values of tblA to tblB without creating duplicate values based on multiple fields. In the following example, FirstName and LastName determine a duplicate, Foo and Source are irrelevant.
tblA:
FirstName LastName Foo Source John Doe 1 A Jane Doe 2 A Steve Smith 3 A Bill Johnson 2 A
tblB:
FirstName LastName Foo Source John Doe 1 B Bob Smith 5 B Steve Smith 4 B
This is the result I want:
tblA:
FirstName LastName Foo Source John Doe 1 A Jane Doe 2 A Steve Smith 3 A Bill Johnson 2 A Bob Smith 5 B
Here's an equivalent of the code I've tried:
INSERT INTO tblA
SELECT B.*
FROM tblB AS B
LEFT JOIN tblA AS A ON A.FirstName = B.FirstName AND A.LastName = B.LastName
WHERE A.FirstName IS NULL
And this is the result I get:
tblA:
FirstName LastName Foo Source John Doe 1 A Jane Doe 2 A Steve Smith 3 A Bill Johnson 2 A John Doe 1 B Bob Smith 5 B
Steve Smith from tblB is ignored, which is good. John Doe from tblB is added, which is bad. I've spent way too much time on this and I've inspected the data every way I can think of to ensure John Doe in tblA and tblB are the same first and last name. Any ideas on what could be going wrong?
Update: FYI, on my real tblB, about 10,000 of 30,000 should be moved to tblA. This is actually moving over 21,000. The problem is this is one step of a common process.