Fix: The OLE DB provider “BULK” for linked server “(null)” reported an error. The provider did not give any information about the error.

Today while working with bulk insert i got below weird error message.

BULK INSERT Testtable FROM ‘\\abcd\testdoc.txt’ WITH
( FIELDTERMINATOR = ‘,’,ROWTERMINATOR = ‘\n’,FIRSTROW = 1 )

Error message:

Msg 4832, Level 16, State 1, Line 2
Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 2
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 2
Cannot fetch a row from OLE DB provider “BULK” for linked server “(null)”.

Cause:

This errors message  mislead us to check linked servers and permissions. but the issue is we missed the FIRSTROW attribute.

Workaround:

i fixed this issue by adding FIRSTROW = 2 attribute to the bulk insert statement.

BULK INSERT Testtable FROM ‘\\abcd\testdoc.txt’ WITH
( FIELDTERMINATOR = ‘,’,ROWTERMINATOR = ‘\n’,FIRSTROW = 2 )