1

I have an Excel file that I import weekly into a table.

I am using Excel 2010 and SSMS 2012. The import failed this week and I have been unable to determine why. I was able to successfully import the data into a new table. The table definitions of the new table match the ones of my old table, so that does not seem to be the issue. Below is a screen shot of the error I receive. I have checked the PO header text field and there is nothing that exceeds the datatype of varchar(255) that I have it as.

Also, I sorted the data just to see if a certain row was causing the issue and more data did insert, but I still got the error and it was not on the same row as the original import attempt. I even dropped and created the original table again and I still receive the error.

enter image description here

4

1 回答 1

2

问题可能是如何Import/Export WizardSSIS获取有关数据类型的元数据的方式。

它使用前几行。如果有一个长字符串(长于 255),则数据类型为 memo,否则为字符串。

一种解决方法是根据文本列降序的长度对 Excel 行进行排序。

Excel 源

截断的文本。

当驱动程序确定 Excel 列包含文本数据时,驱动程序会根据其采样的最长值选择数据类型(字符串或备忘录)。如果驱动程序在其采样的行中未发现任何超过 255 个字符的值,它会将列视为 255 个字符的字符串列而不是备注列。

因此,超过 255 个字符的值可能会被截断 要从备注列导入数据而不截断,您必须确保至少有一个采样行中的备注列包含超过 255 个字符的值,或者您必须增加数量由驱动程序采样的行以包含这样的行。

您可以通过增加 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel 注册表项下的 TypeGuessRows 的值来增加采样的行数。有关详细信息,请参阅 PRB:从 Jet 4.0 OLEDB 源传输数据失败并出现错误。

于 2017-08-23T16:32:11.423 回答