奇数批量插入错误

时间:2012-03-01 20:24:53

标签: sql-server sql-server-2008 bulkinsert

我正在尝试调试SQL Server 2008批量插入内容,而且我收到的错误实际上并没有增加。

T-SQL

BULK INSERT [dbo].SYNC_OFFERDISCOUNTS 
FROM 'c:\inetpub\ftproot\ecometrydev\offer-discounts.csv' 
WITH (BATCHSIZE = 500, FIRSTROW = 2, ROWTERMINATOR = '\n', FIELDTERMINATOR ='||^^||')

我的错误是

  

Msg 4863,Level 16,State 1,Line 3批量加载数据转换错误   (截断)第2行第72列(ACTION_TYPE)。

     

Ms 4663,16级,   状态1,行3行的批量加载数据转换错误(截断)   3,第72栏(ACTION_TYPE)。

     

Msg 4863,Level 16,State 1,Line 3 Bulk   加载第4行第72列的数据转换错误(截断)   (ACTION_TYPE)。

依此类推,直到第12行,此时达到了10个错误,整个事情都被关闭了。我的数据库架构和CSV的部分内容如下。在我看来,I插入的单个字符ACTION_TYPE已被插入,因此我不确定为什么会发生此错误。

修改

令人沮丧的是,文件中只有 71 列,文件的最后一列对应ACTION_TYPE

/修改

我已经尝试将此列增加到varchar(50),并认为创建此csv的遗留系统可能会在某些隐藏的unicode废话中滑落,但这一切都没有改变。

我知道这里有很多垃圾。我已经一次又一次地计算了所有这些零,并且它总是最终确定单个I字符正好插入ACTION_TYPE列。我希望这里的专家可以发现一些模糊的错误。


CSV

DISCOUNTTABLE || || ^^ || MULTIQTY_001 ^^ || || MULTIQTY_002 ^^ || || MULTIQTY_003 ^^ || || MULTIQTY_004 ^^ || || MULTIQTY_005 ^^ || || MULTIQTY_006 ^^ || MULTIQTY_007 || ^^ || MULTIQTY_008 || ^^ || MULTIQTY_009 || ^^ || DISCOUNTPERCENT_001 || ^^ || DISCOUNTPERCENT_002 || ^^ || DISCOUNTPERCENT_003 || ^^ || DISCOUNTPERCENT_004 || ^^ | | DISCOUNTPERCENT_005 || ^^ || DISCOUNTPERCENT_006 || ^^ || DISCOUNTPERCENT_007 || ^^ || DISCOUNTPERCENT_008 || ^^ || DISCOUNTPERCENT_009 || ^^ || DISCOUNTITEM_001 || ^^ || DISCOUNTITEM_002 || ^^ || DISCOUNTITEM_003 || ^^ || DISCOUNTITEM_004 || ^^ || DISCOUNTITEM_005 || ^^ || DISCOUNTITEM_006 || ^^ || DISCOUNTITEM_007 || ^^ || DISCOUNTITEM_008 || ^^ || DISCOUNTITEM_009 || ^^ || DISCOUNTQTY_001 || ^^ || DISCOUNTQTY_002 || ^^ || DISCOUNTQTY_003 || ^^ || DISCOUNTQTY_004 || ^^ || DISCOUNTQTY_005 || ^^ || DISCOUNTQTY_006 || ^^ || DISCOUNTQTY_007 || ^^ || DISCOUNTQTY_008 | | ^^ || DISCOUNTQTY_009 || ^^ || DISCOUNTPRICE_001 || ^^ || DISCOUNTPRICE_002 || ^^ || DISCOUNTPRICE_003 || ^^ || DISCOUNTPRICE_004 || ^^ || DISCOUNTPRICE_005 || ^^ || DISCOUNTPRICE_006 || ^^ || DISCOUNTPRICE_007 || ^^ || DISCOUNTPRICE_008 || ^^ || DISCOUNTPRICE_009 || ^ ^ || DISCOUNTDOL_001 || ^^ || DISCOUNTDOL_002 || ^^ || DISCOUNTDOL_003 || ^^ || DISCOUNTDOL_004 || ^^ || DISCOUNTDOL_005 || ^^ || DISCOUNTDOL_006 || ^^ || DISCOUNTDOL_007 || ^^ || DISCOUNTDOL_008 || ^^ || DISCOUNTDOL_009 || ^^ || ITEMQUANTITY_001 || ^^ || ITEMQUANTITY_002 || ^^ || ITEMQUANTITY_003 || ^^ || ITEMQUANTITY_004 || ^^ || ITEMQUANTITY_005 || ^^ | | ITEMQUANTITY_006 || ^^ || ITEMQUANTITY_007 || ^^ || ITEMQUANTITY_008 || ^^ || ITEMQUANTITY_009 || ^^ || DESC1 || ^^ || DISCOUNTUPSELL || ^^ || USERID || ^^ || DATE || ^^ || TIME || ^^ ||状态|| ^^ || ROWACTION || ^^ ||
0006 || ^^ || 3000 || ^^ || 999999999 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 2000 || ^^ || 2000 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 20%OFF $ 30 +订购|| ^^ ||节省20%30美元+订购|| ^^ || LKWILHEL || ^^ || 20110214 || ^^ || 11141050 || ^ ^ ||%d || ^^ ||我|| ^^ ||
0023 || ^^ || 5000 || ^^ || 999999999 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 1500 || ^^ || 1500 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 15%OFF $ 50 +订购|| ^^ ||节省15%50美元+订购|| ^^ || LKWILHEL || ^^ || 20110214 || ^^ || 11013470 || ^ ^ ||%d || ^^ ||我|| ^^ || 0049 || ^^ || 4600 || ^^ || 999999999 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 3000 || ^^ || 3000 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 0 || ^^ || 30%OFF $ 46 +订购|| ^^ ||节省30%$ 46 +订购|| ^^ || LKWILHEL || ^^ || 20110214 || ^^ || 11384810 || ^ ^ ||%d || || ^^ ||我^^ ||


enter image description here

2 个答案:

答案 0 :(得分:2)

确定行尾(EOL)字符是什么。如果行尾是\ r \ n(并且你只指定了\ n)那么可能是批量插入读入下一行并试图截断它认为是ACTION_TYPE的内容。

使用Notepad ++查找EOL角色的内容。点击查看>显示符号>显示行尾。

答案 1 :(得分:1)

尝试删除SLOTID列,它应该解决问题。 假设SLOTID不作为源文件中的列存在。