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
 Transact-SQL (2000)
 DB2 and Bad Date

Author  Topic 

otto
Starting Member

21 Posts

Posted - 2005-06-24 : 16:35:43
I've been working with SQL 2000 and DB2 Linked Server. The linked server is setup find and I can write a query like this:

SELECT * FROM LinkedServer..Catalog.Table

or

SELECT * FROM OPENQUERY (LinkedServer, 'SELECT * FROM Catalog.Table')

Both queries will run as you would expect.

The problem I'm trying to resolve is that in DB2, I have a couple rows with the following dates:

03/14/0199 and 12/01/0200

DB2 doesn't seem to care that those dates are invalid. When I try and query this table, SQL crashes with the following error: "Error converting data type DBTYPE_DBTIMESTAMP to datetime."

When I write a query that doesn't use OPENQUERY, I can use TSQL syntax. However, ISDATE(col1) will not work because SQL tries to convert the column on the fly before ISDATE is called. Trying to cast the column won't work for the same reason.

If I use OPENQUERY, I'm forced to use DB2 sql syntax, which doesn't have a lot of options for dealing with the date. I'm also not able to use any dynamic sql syntax, so I'd rather not explore this option as I'll run into issue later on.

Anyone else experience anything like this?
   

- Advertisement -