I am trying to upload records from a view into another table only when the record does not exist in the second table. The table being inserted into is a linked server on godaddy and the view is local. Both have hundreds of thousand records. below is what I am currently doing but it takes so long it eventually times out. one thing to note is that typically there would only be 10 to 20 thousand records needed to upload per day.
insert into table b (dateloaded,origzip,opcode,scandate,mailzip,barcodeid,serviceid,mailerid,uniqueid,jobid,scandataid)
select sd.dateloaded,sd.origzip,sd.opcode,sd.scandate,sd.mailzip,sd.barcodeid,sd.serviceid,sd.mailerid,sd.uniqueid,sd.jobid,sd.id from table_view sd
where sd.id not in (select scandataid from table b)
insert into table b (dateloaded,origzip,opcode,scandate,mailzip,barcodeid,serviceid,mailerid,uniqueid,jobid,scandataid)
select sd.dateloaded,sd.origzip,sd.opcode,sd.scandate,sd.mailzip,sd.barcodeid,sd.serviceid,sd.mailerid,sd.uniqueid,sd.jobid,sd.id from table_view sd
where sd.id not in (select scandataid from table b)