我收到此错误
Bulk load data conversion error (truncation) for row 1, column 12 (is_download)
这是csv …它只有一行
30,Bill,Worthy,sales,,709888499,bat@bat.com,,"Im a a people person., to work together for this new emerging env.HTTP://applesoftware.com","Bill and Son of Co","Contact Us: Contact Form",0
这是我的批量插入语句…
SE SalesLogix GO CREATE TABLE CSVTemp (id INT, firstname VARCHAR(255), lastname VARCHAR(255), department VARCHAR(255), architecture VARCHAR(255), phone VARCHAR(255), email VARCHAR(255), download VARCHAR(255), comments VARCHAR(MAX), company VARCHAR(255), location VARCHAR(255), is_download VARCHAR(255) ) GO BULK INSERT CSVTemp FROM 'c:\leads\leads.csv' WITH ( DATAFILETYPE = 'char', BATCHSIZE = 50, FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO --Check the content of the table. SELECT * FROM CSVTemp GO
问题是大多数情况下都能正常工作,但在某些情况下(这是其中一种),我会收到错误消息
关于导致此记录出现此错误的原因的任何想法
由于分隔符不一致,因此它将注释字段中的逗号作为分隔符。最好的解决方案是确保所有字段都用双引号引起来并设置FIELDTERMINATOR为'","'。或者,将逗号替换为注释中不太可能出现的内容(例如~)和set FIELDTERMINATOR = '~'。
FIELDTERMINATOR
'","'
~
FIELDTERMINATOR = '~'