Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error when I try to load 1 BIG .csv file

Author  Topic 

lordoftrades
Starting Member

15 Posts

Posted - 2012-08-29 : 12:17:52
Hello

I have a code that was supposed to load a singel csv file into my database and table. I have tested it with some smaller files, and works fine. But when I try the big file, which is 1,4 GB, it errors.

Could it be some error in the some of the rows, or with some of the separators ","??

The filesize makes it hard to look into it and fix those things.

Any one who knows how to load the file without errors?

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


This is what I get in the messagearea:

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


Kind regards
Espen

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-29 : 12:22:51
The error message indicates it's a badly formatted file. You could try use the first/last switches to load parts of it to narrow it down to where the problem is.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

xhostx
Constraint Violating Yak Guru

277 Posts

Posted - 2012-08-29 : 12:24:58
this maybe helpful!
http://blog.daksatech.com/2011/09/bulk-load-unexpected-end-of-file-was.html

--------------------------
Joins are what RDBMS's do for a living
Go to Top of Page

lordoftrades
Starting Member

15 Posts

Posted - 2012-08-29 : 12:43:20
quote:
Originally posted by tkizer

The error message indicates it's a badly formatted file. You could try use the first/last switches to load parts of it to narrow it down to where the problem is.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



Thank you. I will look that up.

Kind regards
Espen
Go to Top of Page

lordoftrades
Starting Member

15 Posts

Posted - 2012-08-29 : 12:45:45
quote:
Originally posted by xhostx

this maybe helpful!
http://blog.daksatech.com/2011/09/bulk-load-unexpected-end-of-file-was.html

--------------------------
Joins are what RDBMS's do for a living



Thanks :-) I think I understand something in direction of the number of columns, if I have more columns in the .csv file (by a mistake) than what I have created in my table, it will error? I'll try to add some more colums to it, just to see how it works.

Kind regards
Espen
Go to Top of Page
   

- Advertisement -