sqlines icon indicating copy to clipboard operation
sqlines copied to clipboard

Oracle to MSSQL 2016: failed to transfer dates before 01-01-1753

Open ChaosBladeCoder opened this issue 7 years ago • 1 comments

I'm trying to migrate an entire Oracle database to SQL Server, and I'm running into several issues. I will log them separately here.

I'm trying to transfer an Oracle table with a DATE type column, which contains several records with dates before 01-01-1753. Once SQLines encounters the first such record it fails this table with the error "[Microsoft][SQL Server Native Client 11.0]Datetime field overflow".

This happens because SQLines converted the Oracle "DATE" type column to MSSQL type "datetime", which does not support dates before January 1, 1753. [See https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql].

SQLines should instead, whenever possible, convert such columns to type "datetime2", which supports the full range of dates from 0001-01-01 through 9999-12-31. [See https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime2-transact-sql]. This datatype is supported from MSSQL version 2008 and up.

ChaosBladeCoder avatar Oct 31 '17 18:10 ChaosBladeCoder

I should probably note that this situation is not as uncommon as you might think. In my database 16 out of 290 tables failed with this error. Mostly this happens because users make typo's like "204" when trying to type "2004" when entering dates.

ChaosBladeCoder avatar Oct 31 '17 18:10 ChaosBladeCoder