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 6 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply