简体   繁体   English

从Excel 2010导入到SQL Server 2008R2时出错

[英]Error importing to SQL Server 2008R2 from Excel 2010

I am using the SQL Server Import and Export Wizard to try to import a particular xlsx spreadsheet into an existing table in SQL. 我正在使用SQL Server导入和导出向导尝试将特定的xlsx电子表格导入到SQL中的现有表中。 The existing table contains a sub-set of the columns in the spreadsheet and I am ignoring the many columns that don't match. 现有表包含电子表格中各列的子集,而我忽略了许多不匹配的列。

The spreadsheet has 123 columns and 238 lines of data. 该电子表格具有123列和238行数据。

Initially when I was importing the spreadsheet the wizard was hanging on 'Executing' and I had to kill the process. 最初,当我导入电子表格时,向导挂在“执行中”,因此我不得不终止该过程。 Something I have never come across before. 我以前从未遇到过的东西。

After copy and pasting the data into a new spreadsheet it is now coming up with the following error: 将数据复制并粘贴到新的电子表格后,现在出现以下错误:

Error 0xc020901c: Data Flow Task 1: There was an error with output column "Confidentiality Clause Comments" (108) on output "Excel Source Output" (9). 错误0xc020901c:数据流任务1:输出“ Excel Source Output”(9)上的输出列“ Confidentiality Clause Comments”(108)出错。 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) (SQL Server导入和导出向导)

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. 错误0xc020902a:数据流任务1:“输出列“机密条款注释”(108)”失败,因为发生了截断,并且“输出列“机密条款注释”(108)”上的截断行配置指定了截断失败。 A truncation error occurred on the specified object of the specified component. 在指定组件的指定对象上发生了截断错误。 (SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

What I am confused about it, the column "Confidentiality Clause Comments" is one of the columns being ignored - it is not being imported into the database! 我对此感到困惑的是,“机密条款注释”列是被忽略的列之一-它没有被导入数据库!

I have tried setting "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Jet 4.0\\Engines\\Excel\\TypeGuessRows" to both 0 and higher numbers like 238 and 1000 to increase the sample size. 我尝试将“ HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Wow6432Node \\ Microsoft \\ Jet 4.0 \\ Engines \\ Excel \\ TypeGuessRows”设置为0和更高的数字(如238和1000)以增加样本大小。 (Although the table does already exist with fields large enough for the data being imported). (尽管该表已经存在,并且字段足够大,可以导入数据)。 I also have the "On Truncation (global)" and "On Error (global)" set to Ignore (but this setting seems to be 'ignored'). 我还将“截断(全局)”和“错误(全局)”设置为“忽略”(但此设置似乎被“忽略”)。

I have also tried importing the data into a new table, and get the same truncation error message (but on different fields dependant on the data sort). 我还尝试将数据导入到新表中,并得到相同的截断错误消息(但取决于数据排序的不同字段)。

I thought about importing as a CSV file but there are embedded comma's in many of the fields and it completely messed the data up. 我曾考虑过将其导入为CSV文件,但在许多字段中都嵌入了逗号,这完全弄乱了数据。

Any ideas on how to get data imported? 关于如何导入数据的任何想法? I have spent over 3 hours on this already, and have got nowhere. 我已经花了3个多小时,却一无所获。

Thanks,Steve 谢谢,史蒂夫

Instead of CSV, you could save as Text (Tab delimited) (*.txt) - that way you won't encounter the comma problem. 除了CSV之外,您还可以另存为Text (Tab delimited) (*.txt) -这样就不会遇到逗号问题。

Also, if you only need to do this once, and because the dataset is not exactly huge, I'd consider just copying from excel and pasting directly into sql server management studio. 另外,如果您只需要执行一次,并且由于数据集并不十分庞大,我将考虑仅从excel复制并直接粘贴到sql server management studio中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM