title: Trying to avoid duplicate entries for SQL insert from a CSV file import
body: <p>I am trying to import CSV file data to a SQL Server Database. I got more than 15000 rows and it keeps adding new rows everyday to the CSV file. All i need is insert newly added rows to the already existing database. 
  Problem i have right now, if i import the file its gonna insert everything including old 15000 rows. I was thinking to to insert csv data to a temporary table and filter out duplicate lines. but i dont know how to do it.</p>
  
  <pre><code>private void Save_Import_Data_SQL(DataTable importData)
          {
  
              using(SqlConnection conn = new SqlConnection(myconnstring))
              {
                  conn.Open();
                  foreach(DataRow importRow in importData.Rows)
                  {
  
                      DateTime Start_Date_tt = ConvertStringToDate(importRow["Start date"].ToString());
                      Decimal Start_Time_tt = ConvertStringToDecimal(importRow["Start time"].ToString());
                      DateTime Finish_Date_tt = ConvertStringToDate(importRow["Finish date"].ToString());
                      Decimal Finish_Time_tt = ConvertStringToDecimal(importRow["Finish time"].ToString());
  
                      Decimal Pieces_tt = ConvertStringToDecimal(importRow["Pieces"].ToString());
                      Decimal cycle_tt = ConvertStringToDecimal(importRow["Average part cycle time"].ToString());
                      Decimal length_tt = ConvertStringToDecimal(importRow["Length_pa"].ToString());
  
  
                      SqlCommand cmd = new SqlCommand("INSERT INTO Silver_Robot(Program_S,Grpup_S,Start_Date_S,Start_Time_S,Pieces_S,Finish_Date_S,Finish_Time_S,Average_Part_Cycle_Time_S,Mode_S,Length_S) VALUES(@program,@group,@start_Date,@start_time,@pieces,@finish_date,@finish_time,@avarage_part,@mode_p,@length_p)", conn);
  
                      cmd.Parameters.AddWithValue("@program", importRow["Program"]);
                      cmd.Parameters.AddWithValue("@group", importRow["Group"]);
                      cmd.Parameters.AddWithValue("@start_Date", Start_Date_tt);
                      cmd.Parameters.AddWithValue("@start_time", Start_Time_tt);
                      cmd.Parameters.AddWithValue("@pieces", Pieces_tt);
                      cmd.Parameters.AddWithValue("@finish_date", Finish_Date_tt);
                      cmd.Parameters.AddWithValue("@finish_time", Finish_Time_tt);
                      cmd.Parameters.AddWithValue("@avarage_part", cycle_tt);
                      cmd.Parameters.AddWithValue("@mode_p", importRow["Mode"]);
                      cmd.Parameters.AddWithValue("@length_p", length_tt );
                      cmd.ExecuteNonQuery();
                  }
  
              }
          }
  </code></pre>
  
  <p>Any help would be appreciated</p>