title: Fast and simple way to import csv to SQL Server
body: <p>We are importing a csv file with <code>CSVReader</code> then using <code>SqlBulkCopy</code> to insert that data into SQL Server. This code works for us and is very simple, but wondering if there is a faster method (some of our files have 100000 rows) that would also not get too complex?</p>
  
  <pre><code>        SqlConnection conn = new SqlConnection(connectionString);
          conn.Open();
          SqlTransaction transaction = conn.BeginTransaction();
          try
          {
              using (TextReader reader = File.OpenText(sourceFileLocation))
              {
                  CsvReader csv = new CsvReader(reader, true);
                  SqlBulkCopy copy = new SqlBulkCopy(conn, SqlBulkCopyOptions.KeepIdentity, transaction);
                  copy.DestinationTableName = reportType.ToString();
                  copy.WriteToServer(csv);
                  transaction.Commit();
              }
          }
          catch (Exception ex)
          {
              transaction.Rollback();
              success = false;
              SendFileImportErrorEmail(Path.GetFileName(sourceFileLocation), ex.Message);
          }
          finally
          {
              conn.Close();
          }
  </code></pre>