title: Bulk insert CSV file
body: <p>I have a Java code which creates a CSV file and then I use the SQL Sever "BULK INSERT" to insert the data into database; I have no format file. The SQL server is 2008.</p>
  
  <p>When I run the code thru unit test and then run the following sql code everything works fine and the data gets inserted into table:</p>
  
  <pre><code>declare
  @csvFileName VARCHAR (1024)= 'file.csv',
  @csvFormatFileName VARCHAR (1024)= null,
  @tableName VARCHAR (256) = 'tableName';
  
  EXECUTE (       
  'BULK INSERT '+ @tableName +' FROM ''' + @csvFileName + ''' WITH 
  (FIRSTROW=2, FIELDTERMINATOR=''\t'', ROWTERMINATOR=''\n'', MAXERRORS=0);');
  </code></pre>
  
  <p>When my Java code runs in production and creates the CSV files, if I grab one of the CSV files created, and run the above SQL, it gives me no error, however no data is inserted into table, I just get:</p>
  
  <pre><code>(0 row(s) affected)
  </code></pre>
  
  <p>I first thought its the production DB server vs. dev DB server that causes the issue, but that was not the case.</p>
  
  <p>This is the sample data in CSV file:</p>
  
  <pre><code>ID  Date    number1 number2 number3
  
  88  2013-01-14  2   0   0.00
  
  64  2013-01-14  0   0   0.00
  </code></pre>
  
  <p>I cannot see any difference bet. the CSV file that runs with no problem and the one that does not! After all they are created with the same Java code.</p>
  
  <p>Is there any editor that can show me the contents of the files exactly as they are with tab, new line, ...?</p>
  
  <p>Any help is greatly appreciated.</p>