title: Any way to check if data exist in database during an SQL bulk copy
body: <p>I'm copying some data from one SQL Server database to another SQL Server database. </p>
  
  <p>That works fine, what I need is to check if some data already exists, then not copy it. How can I do that? Any suggestions? </p>
  
  <pre><code>string Source = ConfigurationManager.ConnectionStrings["Db1"].ConnectionString;
  string Destination = ConfigurationManager.ConnectionStrings["Db2"].ConnectionString;
  
  using (SqlConnection sourceCon = new SqlConnection(Source))
  {
      SqlCommand cmd = new SqlCommand("SELECT [Id],[Client] FROM [Db1].[dbo].[Client]", sourceCon);
      sourceCon.Open();
  
      using (SqlDataReader rdr = cmd.ExecuteReader())
      {
          using (SqlConnection destCon = new SqlConnection(Destination))
          {
              using (SqlBulkCopy bc = new SqlBulkCopy(destCon))
              {
                      bc.DestinationTableName = "Clients";
                      bc.ColumnMappings.Add("Id", "ClientId");
                      bc.ColumnMappings.Add("Client", "Client");
                      destCon.Open();
  
                      bc.WriteToServer(rdr);
              }
          }
      }
  }
  </code></pre>