Bulk Upload: "unexpected end of file" on the new server

I am trying to do bulk upload in one table in our sql database. Previously, this query worked well when we had a database on another server, but now on the new server I get an error message. Here is all I have: sql bulk import request:

BULK INSERT NewProducts FROM 'c:\newproducts.csv' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO 

And the errors I get are the following:

 Msg 4832, Level 16, State 1, Line 1 Bulk load: An unexpected end of file was encountered in the data file. Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error. Msg 7330, Level 16, State 2, Line 1 Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)". 

Thanks for any help in advance.

+7
sql-server bulkinsert
source share
3 answers

I came across this before, and there are a few things to look for:

  • Make sure your csv file does not have blank lines at the top.
  • Make sure there are no extra blank lines at the end of the file.
  • Make sure the ROWTERMINATOR is actually \n and not \r\n

If you are all three and still get an error, let me know.

0
source share

In my case, the file I was trying to retrieve was in a directory that the SQL Sever process did not have access to. I moved my flat files to a directory that SQL had access to, and this error was resolved.

0
source share

For those who are faced with this question in search of an answer, this error also occurs when the number of columns in your CSV file does not match the columns of the table into which you insert the bulk insert.

0
source share

All Articles