Oracle to SQL2005 DATETIME field overflows in SSIS

前端 未结 4 2033
日久生厌
日久生厌 2021-01-22 20:32

I\'m importing data from Oracle to SQL Server 2005 using SSIS. I think the datetime fields in Oracle are stored to a higher precision than SQL Server 2005 \"DATETIME\" fields wi

相关标签:
4条回答
  • 2021-01-22 21:02

    The issue in this is that SQL Server is limited in what dates are valid (January 1, 1753, through December 31, 9999), while Oracle dates from January 1, 4712 BCE through December 31, 9999. So any date in Oracle less than January 1, 1753 will overflow the datetime sql server datatype.

    If you move up to Sql 2008 you can use Datetime2 type to help with this issue as that has valid dates from 0001-01-01 through 9999-12-31.

    See details here: Sql Server Date and Time types

    And here: Oracle Date Type

    0 讨论(0)
  • 2021-01-22 21:17

    There is another cause. Check to make sure that the dates are valid. We are in the middle of this, and we have years specified as something like 5096, which apparently cannot be moved to SQL server... same goes if you have a year of 0207 instead of 2007.

    0 讨论(0)
  • 2021-01-22 21:22

    I will suggest to use the following instruction in your SELECT statement:

    CASE WHEN date_birth < TO_DATE('01-01-1753','DD-MM-YYYY') THEN NULL
    ELSE to_char(date_birth, 'YYYY-MM-DD HH24:MI:SS') END AS date_birth
    
    0 讨论(0)
  • 2021-01-22 21:28

    Just flagging this as 'answered' since there appears to be no global setting.

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