By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,083 Members | 1,608 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,083 IT Pros & Developers. It's quick & easy.

Bulk load: An unexpected end of file was encountered in the data file.

P: 1
I am trying to import csv file into sql server.

csv file data is

C,FD,20111231,08,000,C,ECB,FLL,FLL,C1,,20111110095 92368,,,,,
C,IS,20111231,05,000,C,KWR,TPA,TPA,F3,,20111110095 92368,,,,,

Bulk insert statement :

BULK INSERT dbo.TB_SAILING_STAG
FROM 'C:\s1.csv'
WITH
(DATAFILETYPE = 'native',
Keepnulls, FIELDTERMINATOR =',',
FORMATFILE ='C:\PersonFormat_n.fmt',
ROWTERMINATOR ='\t',KEEPIDENTITY
)

getting below error

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)".
Nov 10 '11 #1
Share this Question
Share on Google+
3 Replies


P: 5
Looks like your csv file has some control char in the end. Open up in textpad and check for hidden characters.
Nov 11 '11 #2

ck9663
Expert 2.5K+
P: 2,878
You are already using a format file. Let it control how rows are parsed and inserted. You can remove the terminators options.

Good Luck !!!

~~ CK
Nov 13 '11 #3

P: 1
your format file might be like:
1 SQLCHAR 0 4 "" 1 LAYOUT_SYUBETSU Japanese_CI_AS


2 SQLCHAR 0 8 "" 2 DATA_DATE Japanese_CI_AS



use this format :
1 SQLCHAR 0 4 "" 1 LAYOUT_SYUBETSU Japanese_CI_AS
2 SQLCHAR 0 8 "\r\n" 2 DATA_DATE Japanese_CI_AS


means "\r\n" for end of the file in the last statement. This will solve your problem.
let me know if problem still persists.
Jan 21 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.