October 23, 2002 at 1:12 pm
I'm trying to write a Stored Proc that periodically copies data from a source table to another destination table. Both the source and destination tables have the same Primary Keys. The key is a compound key on 3 fields (CustID, Product, Date)
What SQL Statement(s) will ensure that I copy information from the source that is NOT already in the destination table? I can not use MAX(date) condition because orders may come in with past dates. I also cannot drop and recreate the destination table because other fields have data that would be lost.
Any help is appreciated, Thanks.
Matthew Mamet
October 23, 2002 at 4:40 pm
Two ways I can think of. One is to do an outer join so you can identify and exclude the rows already present. The other is to set the index to ignore dupes - though its not an option on a pkey, just 'plain' unique indexes.
Andy
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply