I have two data tables which have a primary key column in common but otherwise different structures as they're created from different tables. I'd like to check which rows are missing from data table B compared to A, with the aim of adding in the missing rows to the database.
I've had a look at questions like this one, which provide good answers but the data tables are usually assumed to be the same.
Since I want to get a list of new rows for inserting, is there any way I can do this without iterating through the rows and checking the PKs? If I'm not mistaken, Merge
will keep the old rows, which I don't want to resubmit to the database.
Both tables will have only a few dozen rows, a couple of hundred maximum. Would the computational hit of doing it row-by-row be negligible anyway?
edit: the two source tables are on different databases/servers, so I can't easily do the comparison in SQL. I'd prefer the consuming application to do it anyway, as I may add some more row processing before I'm done.