Bulkcopy ignoring Primary keys exception

  • Thread starter Thread starter arnoled
  • Start date Start date
A

arnoled

I want to make a bulkcopy (or insertcommand if this can't be
acomplished with bulk copy) to a table. But if there are rows that
are
already in the table, just ignore them (don't do the insert on that
row) , so it doesn't raise an exception of Violation of Primary Key.

I don't want to bring the whole table from de the database, that
would
be very low performant.


If you know any option to do these directly form .net it would be
great, any suggestion is welcome


thanks

(sorry for my english)
 
¤ I want to make a bulkcopy (or insertcommand if this can't be
¤ acomplished with bulk copy) to a table. But if there are rows that
¤ are
¤ already in the table, just ignore them (don't do the insert on that
¤ row) , so it doesn't raise an exception of Violation of Primary Key.
¤
¤ I don't want to bring the whole table from de the database, that
¤ would
¤ be very low performant.
¤
¤
¤ If you know any option to do these directly form .net it would be
¤ great, any suggestion is welcome

SQLBulkCopy is not a selective process. You should only bring in those rows to the DataAdapter or
DataReader that you want copied to the table. This can be accomplished in your SQL statement using
the NOT IN clause with a subquery:

http://msdn2.microsoft.com/en-US/library/ms177682.aspx


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Back
Top