question

sriramya avatar image
sriramya asked

DATE TIME conversion issue in linked server

Hi friends..I have a doubt that i want to get a field from a linked server(DB2) table and my current server is SQL server so when i am trying to get DATE field from linked server it is throwing an error saying **Error converting data type DBTYPE_DBTIMESTAMP to datetime2.** and another doubt is that when i am putting the where condition in the openquery like below it is throwing the error SELECT * FROM OPENQUERY(linked server, 'SELECT * FROM tablename WHERE datecolumn1 < ''2016-05-25 22:42:17.594286'' ') **Result**: This is throwing the error But when i am putting the where condition like in the below query it is not throwing the error SELECT * FROM OPENQUERY(linked server, 'SELECT * FROM tablename') WHERE datecolumn1 < '2016-05-25 22:42:17.594286' Guys i am new to this Can anyone suggest..what is the difference
sql-serverlinked-serveropenquerydb2
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

What does the error message say?
1 Like 1 ·
jmoolman avatar image
jmoolman answered
Hi there, What is the data type of the date column in the DB2 table? I see there is spaces between the date and time of your first query
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sriramya avatar image
sriramya answered
Timestamp in DB2 there are no spaces it was my typo mistake..
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.