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 > DB2 > 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-29-11, 10:30
Mr.Bean Mr.Bean is offline
Registered User
 
Join Date: Dec 2011
Posts: 28
Quote:
Originally Posted by Peter.Vanroose View Post
That will never work!
The whole "Char(...,ISO)" stuff has to go inside the OPENQUERY, since it's DB2 syntax. Outside you need something which is valid SQL Server syntax.

Why not use
Code:
SELECT * FROM OPENQUERY(DB2Server,
'select CustomerID, CHAR(DB2DateColumn, ISO)||'' 00:00:00'', CustAddress
 from DB2Schema.Table')
If you need a nice column name for the second column, add it just before the last comma, e.g.
Code:
SELECT * FROM OPENQUERY(DB2Server,
'select CustomerID,
        CHAR(DB2DateColumn, ISO)||'' 00:00:00'' AS DB2DateColumn,
        CustAddress
 from DB2Schema.Table')
Well when queried as an individual column, it gives me the output. However, if queried with other columns of table, it throws me an error.
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