If you import a file with bulk insert in a stored procedure on a Microsoft SQL Server 2005 database you can get the error:

Error
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)".

In mine case, it was caused by the fact that I used to import the file with a rowterminator of ‘,’ but the code expected a ‘\t’ character as fieldterminator
Code
exec (‘bulk insert dbo.ImportZ from ”’ + @ZFile + ”’ WITH (FIELDTERMINATOR = ”\t”, ROWTERMINATOR = ”\n”)’)

Incorrect fileformat

4,ttt,5,4,1,,eeee
4,ttt,5,4,1,,eeee
4,ttt,5,4,1,,eeee
etc

It can also be caused by a record that has less fields than expected

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.