Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

database

csv

bulk

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.

like image 558
Espen Skeie Avatar asked Aug 27 '12 17:08

Espen Skeie


2 Answers

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' 
like image 136
J. Perkins Avatar answered Sep 19 '22 12:09

J. Perkins


I had same issue.

Solution:

Verify the CSV or textfile in text editors like notepad+. Last line might be incomplete. Remove it.

like image 43
Anil Kumar C Avatar answered Sep 20 '22 12:09

Anil Kumar C