skipping duplicates in mass insert

Anti-Rich

Well-known member
Joined
Jul 1, 2006
Messages
325
Location
Perth, Australia
Programming Experience
1-3
hi all,

ok, i have two excel spreadsheets with huge amounts of information in them. both sheets have 3 fields, IDNumber, Description and Location. the only thing that differs with the two sheets are location (ie. one sheet is building a and the other sheet is building b - e).

my question is, is it possible (after inserting all information from building a) to get all information from building b-e (ie second spreadsheet) and insert it into the database? the catch is, there will be duplicates between the two sheets (ie. item x of id number y is in building a and b). so is there a way i can just skip existing rows when inserting rows from spreadsheet 2, and therefore avoid the program throwing a primary key insert error?

cheers
adam
 
Either:
dont care about the error, and set the tableadapter to continue on error
dedupe the data before it goes in (create a select count(*) from table where key = @key and call it for every row)
use a stored proc that works out whether to update or insert
use Oracle, which is a real database, and has a very nice command called MERGE, which does this :D:D:D
 

Latest posts

Back
Top