title: SQLBulkCopy Don't Copy Primary Keys
body: <p>What is the best way to deal with the primary key violation errors when using SQLBulkCopy  </p>
  
  <pre><code>Violation of PRIMARY KEY constraint 'email_k__'. Cannot insert duplicate key in object  'lntmuser.email'.
  </code></pre>
  
  <p>(i.e. if the row already exists in the destination table) ? </p>
  
  <p>Is there a way to skip inserting duplicate rows or would this have to be checked and dealt with before hand ?</p>
  
  <p>Here is the code I am currently using:</p>
  
  <pre><code>  var conPro = tx_ProConStr.Text;
    var conArc = tx_ArcConStr.Text;
  
    var con = new SqlConnection {ConnectionString = conPro};
    var cmd = new SqlCommand("SELECT * FROM dbo.email", con);
    con.Open();
  
    var rdr = cmd.ExecuteReader(); 
    var sbc = new SqlBulkCopy(conArc) {DestinationTableName = "dbo.email"};
  
    sbc.WriteToServer(rdr);
  
    sbc.Close();
    rdr.Close();
    con.Close();
  </code></pre>