代码之家  ›  专栏  ›  技术社区  ›  Jeremy F.

SSIS-将Oracle日期转换为SQL日期时间

  •  3
  • Jeremy F.  · 技术社区  · 12 年前

    Oracle 11g SQL Server 2008 R2

    当我试图将数据从OLE DB源(Oracle DB)移动到OLE DB目标(SQL Server)时,收到以下错误。在出现错误之前,65000条记录中有8922条已添加到SQL server。8922的日期列中确实添加了一个应该添加的日期。Oracle上的列是DATE类型。SQL Server 2008上的列是日期时间。

    On the SQL Server, for record # 8922 the RSVP_END_DT = 2007-06-25 12:06:00.000
    On the Oracle Server for record # 8922 the RSVP_END_DT = 25-JUN-07
    On the Oracle Server, for what should be record # 8923 in the SQL DB, the RSVP_END_DT = 10-AUG-07
    

    我搜索了每个“DTE_E”错误,但没有找到任何帮助。我还尝试过使用数据转换并编写源SQL,以正确的SQL格式将日期设置为“to_char”,但这也不起作用。有人有其他建议吗?

    [OLE DB Destination [424]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E21.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80040E21  Description: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.".
    
    [OLE DB Destination [424]] Error: There was an error with input column "RSVP_END_DT" (487) on input "OLE DB Destination Input" (437). The column status returned was: "Conversion failed because the data value overflowed the specified type.".
    
    [OLE DB Destination [424]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "input "OLE DB Destination Input" (437)" failed because error code 0xC020907A occurred, and the error row disposition on "input "OLE DB Destination Input" (437)" 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.
    
    [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "OLE DB Destination" (424) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (437). 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.
    
    [OLE_DB_SOURCE[1]] Error: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
    
    [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on component "OLE_DB_SOURCE" (1) 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.
    
    2 回复  |  直到 12 年前
        1
  •  3
  •   Community Dan Abramov    7 年前

    以下是我之前关于这个话题的三个答案。您很可能超出了出现该错误消息的Sql Server日期范围。我在最后一个答案中解释了Datetime和datetime2的不同限制。

    https://stackoverflow.com/a/11585853/236348

    https://stackoverflow.com/a/2231164/236348

    https://stackoverflow.com/a/11229159/236348

        2
  •  0
  •   praveen    12 年前

    从OLEDB源获取数据时,将源日期列转换为指定格式,如

    YYYY MM DD
    Select  TO_CHAR(DateColumn,'yyyy/mm/dd') as CustomDate from yourTable
    

    不确定引用的语法 this 文章 与其使用To_Char,不如使用一些oracle预定义的函数以正确的格式获取日期。在源数据进入SSIS管道之前,最好对其进行丰富或转换,以便进一步丰富

    然后在派生列中将此字符串转换为您的sqlserver日期时间格式

    convert(datetime, CustomDate , 111)
    

    在SQl服务器中,我会使用isDate函数检查列 或者会尝试将值转换为特定格式

    CASE WHEN isDate(DateColumn) = 1 THEN DateColumn ELSE NULL END as DateColumn
    or
    convert(datetime, '25-JUN-07', 106) -- dd.mm.yyyy