且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用导入向导将Excel数据导入SQL Server 2012中的表失败-文本截断

更新时间:2023-02-04 15:28:17

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

The problem is probably the way how Import/Export Wizard or SSIS get metadata about datatypes.

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

It uses first few rows. If there is a long string (longer than 255) then datatype is memo, otherwise is string.

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

One workaround is to sort Excel rows based on length on text column descending.

来自 Excel来源

截断的文本.

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

因此,长度超过255个字符的值可能会被截断.要从备忘录列中导入数据而不被截断,必须确保至少一个采样行中的备忘录列包含的长度超过255个字符,否则,您必须增加驱动程序采样的行数才能包含该行.

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

You can increase the number of rows sampled by increasing the value of TypeGuessRows under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel registry key. For more information, see PRB: Transfer of Data from Jet 4.0 OLEDB Source Fails w/ Error.