我正在尝试将带有国家/地区列表的Excel文件导入我的SQL Server数据库,但是我收到此错误。什么可能是错的?
验证(错误)
消息
错误0xc020201b:数据流任务1:目标 - Countries.Inputs [目标输入]的输入列数不能为零。 (SQL Server导入和导出向导)错误0xc004706b:数据流任务1:“目标 - 国家/地区”验证失败并返回验证状态“VS_ISBROKEN”。
(SQL Server导入和导出向导)错误0xc004700c:数据流任务1:一个或多个组件验证失败 (SQL Server导入和导出向导)
错误0xc0024107:数据流任务1:任务验证期间出现错误 (SQL Server导入和导出向导)
这是我在Excel中列表的预览:
所以当我第一次导入临时表,然后尝试复制到我的表中时,我收到此错误:
- Copying to [dbo].[Countries] (Error)
Messages
Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "Unspecified error".
(SQL Server Import and Export Wizard)
Error 0xc020901c: Data Flow Task 1: There was an error with Destination - Countries.Inputs[Destination Input].Columns[countryId] on Destination - Countries.Inputs[Destination Input]. The column status returned was: "The value violated the integrity constraints for the column.".
(SQL Server Import and Export Wizard)
Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Destination - Countries.Inputs[Destination Input]" failed because error code 0xC020907D occurred, and the error row disposition on "Destination - Countries.Inputs[Destination Input]" specifies failure on error. 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)
Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Destination - Countries" (46) failed with error code 0xC0209029 while processing input "Destination Input" (59). The identified component returned an error from the ProcessInput method. 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)
当我执行查询时,我得到:
Msg 2627, Level 14, State 1, Line 6
Violation of PRIMARY KEY constraint 'PK_dbo.Countries'. Cannot insert duplicate key in object 'dbo.Countries'. The duplicate key value is (1).
The statement has been terminated.
(26行受影响)
答案 0 :(得分:1)
您必须在excel文件中进行数据清理。我想您正在尝试导入到一个EXISTING表。
我建议遵循工作流程。
编辑:
使用导入/导出向导Column Mappings时,请选择目标表作为新表名,例如tempExcelImport
目的地
标识选定的目标表,视图或查询。
创建目标表/文件
指定是否创建目标表(如果目标表尚不存在)。