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

前端 未结 2 1014
走了就别回头了
走了就别回头了 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.

    0 讨论(0)
  • 2020-12-11 12:06

    I realize you have the fix you wanted, but the other method for dealing with issues of this sort is to use a conditional split. You can find and handle all sorts of data issues where you want to remove records from the main flow and do specific handling of them using conditional split. I find it especially handy when I want to be able to tell the vendor about the bad records they sent us so they can fix their data.

    0 讨论(0)
提交回复
热议问题