我正在使用 SQL Server 导入和导出向导尝试将特定的 xlsx 电子表格导入 SQL 中的现有表。现有表格包含电子表格中列的子集,我忽略了许多不匹配的列。
电子表格有 123 列和 238 行数据。
最初,当我导入电子表格时,向导卡在“正在执行”上,我不得不终止该进程。我以前从未遇到过的事情。
将数据复制并粘贴到新电子表格后,出现以下错误:
Error 0xc020901c: Data Flow Task 1: There was an error with output column "Confidentiality Clause Comments" (108) on output "Excel Source Output" (9). The column status returned was: "Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)
Error 0xc020902a: Data Flow Task 1: The "output column "Confidentiality Clause Comments" (108)" failed because truncation occurred, and the truncation row disposition on "output column "Confidentiality Clause Comments" (108)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component. (SQL Server Import and Export Wizard)
令我感到困惑的是,“保密条款注释”列是被忽略的列之一 - 它没有被导入数据库!
我尝试将“HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet 4.0\Engines\Excel\TypeGuessRows”设置为 0 和更高的数字(如 238 和 1000)以增加样本量。 (尽管该表确实已经存在,其中的字段足够大,可以导入数据)。我还将“截断时(全局)”和“出错时(全局)”设置为忽略(但此设置似乎被“忽略”)。
我也试过将数据导入新表,并得到相同的截断错误消息(但在不同的字段上取决于数据排序)。
我考虑过导入为 CSV 文件,但许多字段中嵌入了逗号,这完全弄乱了数据。
关于如何导入数据有什么想法吗?我已经为此花费了 3 个多小时,但一无所获。
谢谢,史蒂夫
最佳答案
除了 CSV,您可以另存为 文本(制表符分隔)(*.txt)
- 这样您就不会遇到逗号问题。
此外,如果您只需要执行一次,并且因为数据集不是很大,我会考虑直接从 excel 复制并直接粘贴到 sql server management studio 中。
关于sql - 从 Excel 2010 导入到 SQL Server 2008R2 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14649762/