Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 DB2 low dates (0001-01-01) and DTS

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-04-26 : 09:32:55
ks writes "I am trying to import DB2 tables to SQL Server 2000 using DTS. DB2 tables contain date fields that contain the value "0001-01-01" DTS does not like this date and gives an invalid date error message. I do not want to use varchar as I will not be able to use the date functions in reports. I have no control over the DB2 tables and these tables are huge.

Is there any way to import these tables using shortdatetime in DTS?

Thanks"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-04-26 : 09:42:04
There's no way to make this date value fit a SQL Server date, it's out of the accepted range. You can write a DB2 query with a CASE expression to convert out-of-range dates:

SELECT CASE WHEN myDate<'17530101' THEN Null ELSE myDate END as myDate, col1, col2 FROM myDB2Table
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-26 : 10:30:38
or

SELECT CASE WHEN IsDate(myDate)=0 THEN Null ELSE myDate END as myDate, col1, col2 FROM myDB2Table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-04-26 : 18:20:59
IsDate() is not a valid DB2 function. He would have to import is as varchar before he could run that test, which pretty much defeats the purpose.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-27 : 01:31:40
Thanks. I didnt know that DB2 doesnt support IsDate()

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -