使用导入向导将 Excel 数据导入 SQL Server 2012 中的 table 失败 - 文本截断
Using Import wizard to import Excel data into table in SQL Server 2012 failing - text truncation
我有一个 Excel 文件,我每周将其导入 table。
我正在使用 Excel 2010 和 SSMS 2012。本周导入失败,我一直无法确定原因。我能够成功地将数据导入新的 table。新 table 的 table 定义与我的旧 table 的定义相匹配,因此这似乎不是问题所在。下面是我收到的错误的屏幕截图。我已经检查了 PO header 文本字段,没有任何内容超出我所拥有的 varchar(255) 的数据类型。
此外,我对数据进行了排序,只是为了查看是否是某一行导致了问题,并且确实插入了更多数据,但我仍然遇到错误,并且它与原始导入尝试不在同一行。我什至再次删除并创建了原始 table,但我仍然收到错误。
问题可能是 Import/Export Wizard
或 SSIS
获取有关数据类型的元数据的方式。
它使用前几行。如果有一个长字符串(长于 255)则数据类型为 memo,否则为 string.
一种解决方法是根据文本列的长度降序对 Excel 行进行排序。
From Excel Source
Truncated text.
When the driver determines that an Excel column contains text data, the driver selects the data type (string or memo) based on the longest value that it samples. If the driver does not discover any values longer than 255 characters in the rows that it samples, it treats the column as a 255-character string column instead of a memo column.
Therefore, values longer than 255 characters may be truncated To import data from a memo column without truncation, you must make sure that the memo column in at least one of the sampled rows contains a value longer than 255 characters, or you must increase the number of rows sampled by the driver to include such a row.
You can increase the number of rows sampled by increasing the value of TypeGuessRows under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet.0\Engines\Excel registry key. For more information, see PRB: Transfer of Data from Jet 4.0 OLEDB Source Fails w/ Error.
我有一个 Excel 文件,我每周将其导入 table。
我正在使用 Excel 2010 和 SSMS 2012。本周导入失败,我一直无法确定原因。我能够成功地将数据导入新的 table。新 table 的 table 定义与我的旧 table 的定义相匹配,因此这似乎不是问题所在。下面是我收到的错误的屏幕截图。我已经检查了 PO header 文本字段,没有任何内容超出我所拥有的 varchar(255) 的数据类型。
此外,我对数据进行了排序,只是为了查看是否是某一行导致了问题,并且确实插入了更多数据,但我仍然遇到错误,并且它与原始导入尝试不在同一行。我什至再次删除并创建了原始 table,但我仍然收到错误。
问题可能是 Import/Export Wizard
或 SSIS
获取有关数据类型的元数据的方式。
它使用前几行。如果有一个长字符串(长于 255)则数据类型为 memo,否则为 string.
一种解决方法是根据文本列的长度降序对 Excel 行进行排序。
From Excel Source
Truncated text.
When the driver determines that an Excel column contains text data, the driver selects the data type (string or memo) based on the longest value that it samples. If the driver does not discover any values longer than 255 characters in the rows that it samples, it treats the column as a 255-character string column instead of a memo column.
Therefore, values longer than 255 characters may be truncated To import data from a memo column without truncation, you must make sure that the memo column in at least one of the sampled rows contains a value longer than 255 characters, or you must increase the number of rows sampled by the driver to include such a row.
You can increase the number of rows sampled by increasing the value of TypeGuessRows under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet.0\Engines\Excel registry key. For more information, see PRB: Transfer of Data from Jet 4.0 OLEDB Source Fails w/ Error.