Dealing with Timestamp/Datetime when copying data from Oracle to SQL Server using SSIS

前端 未结 2 1020
走了就别回头了
走了就别回头了 2020-12-11 11:31

I am using SSIS to copy data from a table in Oracle to a table in SQL Server 2005. There\'s no transformation required, so it\'s just a straight line connecting OLE DB Sour

2条回答
  •  清歌不尽
    2020-12-11 11:56

    I usually let Oracle deal with that by using something like this in my source query:

    CAST( Coalesce (
    CASE 
     WHEN TO_CHAR(Effective_Date,'yyyy-mm-dd HH24:MI:SS') < '1900-01-01 00:00:00' 
           THEN TO_DATE('9999-12-31 00:00:00','yyyy-mm-dd HH24:MI:SS') 
     ELSE Effective_Date 
    END ,TO_DATE('9999-12-31 00:00:00','yyyy-mm-dd HH24:MI:SS')) AS DATE) AS Effective_Date
    

    This sets a valid but very future date (dictated by the company I am on contract to as the representation of an invalid date in a required date field. You could also use '1900-01-01 00:00:00' instead of '9999-12-31 00:00:00') in cases where the original date is null or less than 1900-01-01 00:00:00. It also avoids post processing by SSIS on the date field.

提交回复
热议问题