简体   繁体   English

从Excel文件导入SQL Server 2008 R2中的表时出错

[英]Error while importing into table in SQL Server 2008 R2 from Excel File

I am getting this error while importing from an Excel file into a table in SQL Server 2008 R2. 从Excel文件导入到SQL Server 2008 R2中的表时,我收到此错误。

I have added a picture. 我添加了一张图片。

Copying to [dbo].[MultiPLU] (Error) Messages Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR. 复制到[dbo]。[MultiPLU](错误)消息错误0xc0202009:数据流任务1:SSIS错误代码DTS_E_OLEDBERROR。 An OLE DB error has occurred. 发生OLE DB错误。
Error code: 0x80004005. 错误代码:0x80004005。 An OLE DB record is available. OLE DB记录可用。
Source: "Microsoft SQL Server Native Client 10.0" 来源:“Microsoft SQL Server Native Client 10.0”
Hresult: 0x80004005 Description: "The statement has been terminated.". Hresult:0x80004005描述:“声明已经终止。”

An OLE DB record is available. OLE DB记录可用。
Source: "Microsoft SQL Server Native Client 10.0" 来源:“Microsoft SQL Server Native Client 10.0”
Hresult: 0x80004005 Hresult:0x80004005
Description: "Cannot insert the value NULL into column 'PLUCode', table 'AR4UWin.dbo.MultiPLU'; column does not allow nulls. INSERT fails.". 说明:“无法将值NULL插入列'PLUCode',表'AR4UWin.dbo.MultiPLU';列不允许空值.INSERT失败。”
(SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. 错误0xc0209029:数据流任务1:SSIS错误代码DTS_E_INDUCEDTRANSFORMFAILUREONERROR。 The "input "Destination Input" (57)" failed because error code 0xC020907B occurred, and the error row disposition on "input "Destination Input" (57)" specifies failure on error. “输入”目标输入“(57)”失败,因为发生错误代码0xC020907B,并且“输入”目标输入“(57)”上的错误行处置指定错误失败。 An error occurred on the specified object of the specified component. 指定组件的指定对象发生错误。 There may be error messages posted before this with more information about the failure. 在此之前可能会发布错误消息,其中包含有关失败的更多信息。
(SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED. 错误0xc0047022:数据流任务1:SSIS错误代码DTS_E_PROCESSINPUTFAILED。 The ProcessInput method on component "Destination - MultiPLU" (44) failed with error code 0xC0209029 while processing input "Destination Input" (57). 组件“Destination - MultiPLU”(44)上的ProcessInput方法在处理输入“Destination Input”(57)时失败,错误代码为0xC0209029。 The identified component returned an error from the ProcessInput method. 标识的组件从ProcessInput方法返回错误。 The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. 该错误特定于组件,但错误是致命的,将导致数据流任务停止运行。 There may be error messages posted before this with more information about the failure. 在此之前可能会发布错误消息,其中包含有关失败的更多信息。

(SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

导入过程需要“PLUCode”列中每一行的值,而我相信您的Excel电子表格有时在这些单元格中没有值。

Right clicking on the PLUCode and setting it to allow nulls will allow you to upload the table. 右键单击PLUCode并将其设置为允许空值将允许您上载表。 The query below will give you the errored entries for review. 下面的查询将为您提供错误的条目以供审核。

SELECT *
FROM Tablename
WHERE PLUCode IS NULL

If you're dealing with duplicates I would recommend a self join to only give you the unique rows. 如果您正在处理重复项,我建议您使用自联接来仅为您提供唯一的行。 (You'll need a few 'if' statements to check for rows with null values so you don't delete a whole record and leave you with the broken one.) I would be exceptionally careful with using any predefined remove duplicates function (like in excel) unless you've scrutinized the table to ensure it wont drop the completed rows. (你需要一些'if'语句来检查具有空值的行,这样你就不会删除整个记录并留下破坏的记录。)我会非常小心地使用任何预定义的删除重复项功能(如在excel中)除非你仔细检查表,以确保它不会丢弃已完成的行。

EDIT: To respond the need to save as a flat file you'll want to save as a comma delimited csv file. 编辑:要响应需要保存为平面文件,您需要保存为逗号分隔的csv文件。 Its in the usual file formats list unless you're using excel 2010, the itll be under the "Save and Send" option. 它在通常的文件格式列表中,除非你使用excel 2010,它将在“保存并发送”选项下。

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

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