January 9, 2012 at 4:44 am
Hi,
I am trying to bulk load data from a txt file into a table.
I keep receiving this error from SQL Server:
Msg 4832, Level 16, State 1, Line 1
Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 1
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 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
The file as the following structure:
Sessao|CODRF|
7|4.01|
It's in the right place and with the right name. Can someone help undestand why this message happens?
Thanks.
January 9, 2012 at 4:49 am
Bulk command:
exec('BULK INSERT sessoes1 FROM ''c:\sgrs\SGRS_SGCTCentral_7_20111111102846.rar_Dir\sessao.txt''
with (FIRSTROW =2,FIELDTERMINATOR =''|'',
ROWTERMINATOR =''|'', tablock)')
Table structure:
create table Sessoes1(Sessao int, Codrf varchar(5))
January 9, 2012 at 5:54 am
this errors comes usually if the file is opened While running the bulk insert command.
January 9, 2012 at 6:04 am
the file is not open.
It's closed.
January 9, 2012 at 7:31 am
Re-write the query to match with this example...
Example:
DECLARE @bulk_cmd varchar(1000)
SET @bulk_cmd = 'BULK INSERT AdventureWorks2008R2.Sales.SalesOrderDetail
FROM ''<drive>:\<path>\<filename>''
WITH (ROWTERMINATOR = '''+CHAR(10)+''')'
EXEC(@bulk_cmd) -- Focus here
January 10, 2012 at 7:30 am
make sure you check for an extra carriage return in your source text file (ie., extra line with no content).
January 10, 2012 at 1:31 pm
I don't think ROWTERMINATOR should be pipe '|'. It should be '\r' or '\n' or '\r\n'. The latter is default.
--Vadim R.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply