If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > How to Convert a DB2 'Date' Datatype to a SQL Server 'DateTime' Dataype?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #16 (permalink)  
Old 12-27-11, 14:30
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,280
Quote:
Originally Posted by aflorin27 View Post
DB2 error messages are not so "user-friendly" as the SQL Server ones. But you may find some useful clues when searching on the Internet the SQLSTATE error codes.
Google eg. "db2 SQLSTATE: 42605, SQLCODE: -170" for a more elaborate error messages.

There is a way to tell DB2, in the connect string, to do the lookup for you and give a more verbose error message, but I forgot how to do it. You may want to post that question on the DB2 forum.
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #17 (permalink)  
Old 12-28-11, 04:17
aflorin27 aflorin27 is offline
Registered User
 
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
Quote:
Originally Posted by Mr.Bean View Post
I've tried it too but it throwed me the same error:

Invalid Object Name
This is strange - sysibm.sysdummy1 should have SELECT privilege granted to PUBLIC. Anyway, the error message tells me that the DB2 connection works just fine.

So, according to this: Data Type Mapping with Distributed Queries this should work:

SELECT CAST(DateColumn AS DATETIME) FROM OPENQUERY(DB2Server, 'select DB2DateColumn from DB2Schema.Table')
__________________
Florin Aparaschivei
Iasi, Romania
Reply With Quote
  #18 (permalink)  
Old 12-29-11, 10:26
Mr.Bean Mr.Bean is offline
Registered User
 
Join Date: Dec 2011
Posts: 28
Quote:
Originally Posted by aflorin27 View Post
This is strange - sysibm.sysdummy1 should have SELECT privilege granted to PUBLIC. Anyway, the error message tells me that the DB2 connection works just fine.

So, according to this: Data Type Mapping with Distributed Queries this should work:

SELECT CAST(DateColumn AS DATETIME) FROM OPENQUERY(DB2Server, 'select DB2DateColumn from DB2Schema.Table')
I've tried this earlier itself. When queried as a single column it shows the result as:

Code:
2002-12-09
without 00:00:00.000 appended to it.
Reply With Quote
Reply

Tags
convert to sql, db2, sql 2000

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On