title: How to import a very large csv file into an existing SQL Server table?
body: <p>I have a very large csv file with ~500 columns, ~350k rows, which I am trying to import into an existing SQL Server table.</p>
  
  <p>I have tried <code>BULK INSERT</code>, I get - <code>Query executed successfully, 0 rows affected</code>. Interestingly, <code>BULK INSERT</code> worked, in a matter of seconds, for a similar operation but for a much smaller csv file, less than 50 cols., ~77k rows.</p>
  
  <p>I have also tried <code>bcp</code>, I get - <code>Unexpected EOF encountered in BCP data-file. BCP copy in failed</code>. </p>
  
  <p>The task is simple - it shouldn't be hard to the limits of pure frustration. Any ideas or suggestions? Any other tools, utilities that you have successfully used to accomplish a bulk import operation or something similar? Thanks.</p>
  
  <p>-- BULK INSERT  </p>
  
  <pre><code>USE myDb  
  BULK INSERT myTable  
  FROM 'C:\Users\myFile.csv'  
  WITH  
  (  
  FIRSTROW = 2,  
  -- DATAFILETYPE = 'char',  
  -- MAXERRORS = 100,  
  FIELDTERMINATOR = ',',  
  ROWTERMINATOR = '\n'  
  );
  </code></pre>
  
  <p>-- bcp  </p>
  
  <pre><code>bcp myDb.dbo.myTable in 'C:\Users\myFile.csv' -T -t, -c
  </code></pre>
  
  <p><em>UPDATE</em><br>
  I have now changed course. I've decided to join the csv files, which was my goal to begin with, outside of SQL Server so that I don't have to upload the data to a table for now. However, it'll be interesting to try to upload (BULK INSERT or 'bcp') only 1 record (~490 cols.) from the csv file, which otherwise failed, and see if it works.</p>