2017-06-05 91 views
0

傢伙,導入Excel數據導入SQL Server和轉換爲DateTime

我在一個Excel文件中得到了一些datetime數據,爲SQL Server日期時間轉換(YYYY-MM-DD HH適當格式:MM:SS: 000)。不幸的是,當我嘗試將數據導入到DateTime類型的SQL領域,我得到這些錯誤消息:

Error 0xc02020c5: Data Flow Task 1: Data conversion failed while converting column "Datetime" (27) to column "Datetime" (60). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data." 

Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Data Conversion 0 - 0.Outputs[Data Conversion Output].Columns[Datetime]" failed because error code 0xC020907F occurred, and the error row disposition on "Data Conversion 0 - 0.Outputs[Data Conversion Output].Columns[Datetime]" 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. 

Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Data Conversion 0 - 0" (52) failed with error code 0xC0209029 while processing input "Data Conversion Input" (53). 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. 

Error 0xc02020c4: Data Flow Task 1: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020. 

Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - Sheet2$ returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure. 

什麼我做錯了任何想法?我特別需要從Excel導入,而不是從CSV導入,因爲源文件中存在希伯來語文本,SQL Server拒絕使用CSV導入中提供的任何編碼進行識別。

`

+0

日期時間(27)和數據時間(60)似乎是單獨的格式。嘗試將excel列更改爲與您的sql日期格式相匹配的自定義格式日期,這取決於您的語言設置。 – bsivel

+0

excel列的格式當前是自定義日期時間:yyyy-mm-dd hh:mm:ss.000。我應該怎樣改變它? –

+0

您可能想在ss和000之間嘗試一段時間而不是冒號。如果仍然無法正常工作,可以嘗試導入爲字符串,然後使用cast()後導入。 – SMM

回答

0

終於完成的工作是完全刪除毫秒。