2013-03-06 184 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