When I run this SELECT statement, I receive 642 rows…
SELECT *
FROM _DevLoadIn a
JOIN ArticleCompanyList b ON b.Company = a.Name
When I run this UPDATE statement, only 630 rows are updated…
UPDATE b
SET b.BGCompanyId = a.RelatedId
FROM _DevLoadIn a
JOIN ArticleCompanyList b ON b.Company = a.Name
The JOIN is identical, so how can the number of effected rows be different? Both statements execute without error. I don’t see how this could be possible. Can anyone provide any insight? Am I missing something about how an update/join works?
Best guess is that there are more matches in A for each value of B. So the
selectstatement returns the joined duplicates of A – but theupdateonly updates the row once.In other words, the additional values in your select are representations of B (not A).
—- updated post question edit —–
Are you sure that your are updating the right value? Make sure that the proper table (A or B) is on the left hand side of the update statement. It appears you’ve edited your question and switched places of what was originally posted. The theory is still the same however.