Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)"

Espen Skeie picture Espen Skeie · Aug 27, 2012 · Viewed 83.6k times · Source

I try to load my database with tons of data from a .csv file sized 1.4 GB. But when I try to run my code I get errors.

Here's my code:

USE [Intradata NYSE] 
GO
CREATE TABLE CSVTest1
(Ticker varchar(10) NULL,
dateval date NULL,
timevale time(0) NULL,
Openval varchar(10) NULL,
Highval varchar(10) NULL,
Lowval varchar(10) NULL,
Closeval varchar(10) NULL,
Volume varchar(10) NULL
)
GO

BULK
INSERT CSVTest1
FROM 'c:\intramerge.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
--Check the content of the table.
SELECT *
FROM CSVTest1
GO
--Drop the table to clean up database.
DROP TABLE CSVTest1
GO

I try to build a database with lots of stockquotes. But I get this 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)"

I do not understand much of SQL, but I hope to catch a thing or two. Hope someone see what might be very obvious.

Answer

J. Perkins picture J. Perkins · Nov 13, 2015

Resurrecting an old question, but in case this helps someone else: after much trial-and-error I was finally (finally!) able to get rid of this error by changing this:

ROWTERMINATOR = '\n'

To this:

ROWTERMINATOR = '0x0A'