2013-03-06 293 views
3

我知道这个问题可能会重复。但是,我得到的问题与此不同。我已经创建了没有数据的表“CRM_Doctor_Budget”。在sql server 2008中导入excel文件

Table Created in sql server 2008

我想从excel文件该表中插入数据。

我正在使用导入和导出数据(32位)。

接着步骤我做的:

First step

Second step

third step

5th step

6th step

7th Step

8th step

错误,我越来越:

- Validating (Error) 
Messages 
Error 0xc0202049: Data Flow Task 1: Failure inserting into the read-only column "Id". 
(SQL Server Import and Export Wizard) 

Error 0xc0202045: Data Flow Task 1: Column metadata validation failed. 
(SQL Server Import and Export Wizard) 

Error 0xc004706b: Data Flow Task 1: "component "Destination - CRM_Doctor_Budget" (59)" failed validation and returned validation status "VS_ISBROKEN". 
(SQL Server Import and Export Wizard) 

Error 0xc004700c: Data Flow Task 1: One or more component failed validation. 
(SQL Server Import and Export Wizard) 

Error 0xc0024107: Data Flow Task 1: There were errors during task validation. 
(SQL Server Import and Export Wizard) 

我在转换VARCHAR,INT,SMALLINT位数据类型收到错误。因为excel文件具有所有数据的通用数据类型。在我已经创建的表中,我有varchar,int,float,smallint和bit。

检查后,“启用标识插入”我得到更少的错误,但错误如下:

Copying to [dbo].[CRM_Doctor_Budget] (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 10.0" Hresult: 0x80004005 Description: "Unspecified error". 
(SQL Server Import and Export Wizard) 

Error 0xc020901c: Data Flow Task 1: There was an error with input column "Id" (143) on input "Destination Input" (72). 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 "input "Destination Input" (72)" failed because error code 0xC020907D occurred, and the error row disposition on "input "Destination Input" (72)" 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 - CRM_Doctor_Budget" (59) failed with error code 0xC0209029 while processing input "Destination Input" (72). 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) 
+0

您是否尝试将其保存为csv文件,然后使用tsql批量插入?语法很简单。批量插入[表名]从[filepath.csv]与(ROWTERMINATOR =“\ n”,FIELDTERMINATOR =“”)只需砍列标题出CSV文件的。 – 2013-03-06 15:46:10

回答

2

我已经解决了这个问题。我做了一些更改,如:

在编辑映射:因为我有ID作为标识列,它是自动生成的列。

如前所述,我已经映射Id列。

现在这个时候我没有地图标识列,并选中“启用我的身份插入”

否则我执行步骤,因为它是..这微小的变化我已经做了,我得到的记录成功导入。 :)谢谢大家的帮助。

1

是ID列标识列?因为如果是这样,你需要点击“启用身份插入”复选框才能使其工作。

+0

我已经尝试了您的建议是我的ID列是标识列。所以我尝试使用“启用身份插入”,它比以前更好。感谢那。 – 2013-03-07 05:07:34

+0

@anshu - 好了,你与我得到下一个错误倒是列是它违反完整性约束。 Id列是否也是主键,并且您在此列中的CSV内是否有重复项?或者是否有一些CSV格式错误,意味着您要将文本数据导入Id列等? – steoleary 2013-03-07 06:31:41