Link to home
Start Free TrialLog in
Avatar of Amanda Walshaw
Amanda WalshawFlag for Australia

asked on

sql 2008 insert table - data conversion error (truncation)

insert issues for sql bulk insert, inserting by csv file
TRUNCATE TABLE dbo.NaturalAccount

BULK

INSERT dbo.NaturalAccount

FROM '\\myserver\myfolder\NATURALACCOUNT.CSV'

WITH

(

FIELDTERMINATOR = ',',

ROWTERMINATOR = '\n',

FIRSTROW=1

)

GO

getting the error
Msg 4863, Level 16, State 1, Line 2
Bulk load data conversion error (truncation) for row 78, column 4 (Account_type).
Msg 4863, Level 16, State 1, Line 2

 
Please find attached error log and csv file I am trying to upload.  It only happens on certain lines and the data is fine.  the column is varchar 3. it will always contain 3 numericals ie 100, 150, 160

I would appreciate your help here.  Please find attached files.
error.txt
NaturalAccount.csv
SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes you have some "embedded" comma in the data especially in column 3....
I have converted csv file to excel and problem solved. the excel file is attached.
NaturalAccount.xls
Avatar of Amanda Walshaw

ASKER

Hello pourfard have done this but now getting the error

Msg 4863, Level 16, State 1, Line 2
Bulk load data conversion error (truncation) for row 1, column 1 (Code).
Msg 4866, Level 16, State 8, Line 2
The bulk load failed. The column is too long in the data file for row 1, column 13. Verify that the field terminator and row terminator are specified correctly.
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)".

Still using the script

TRUNCATE TABLE dbo.Fin_DIM_NaturalAccount
BULK
INSERT dbo.Fin_DIM_NaturalAccount
FROM '\\myserver\myfolder\NATURALACCOUNT.xls'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
FIRSTROW=1
)
GO
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial