Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1297
  • Last Modified:

How to pass date as a parameter in select * from OPENQUERY(SERVER,'select * from table where date = 4/23/2005')

Hi,

I have got a linked server...and need to query data from a table by passing a date parameter....the following is the statement which i am using,

select * from openquery(SERVER,'select * from table where date_time = 4/23/2005')

and am getting the following error...

OLE DB provider 'MSDASQL' reported an error.  
[OLE/DB provider returned message: [SimbaLNA][Simba][SimbaEngine ODBC Driver]Error in predicate: date_time = 4 / 23 / 2005]
[OLE/DB provider returned message: [SimbaLNA][Simba][SimbaEngine ODBC Driver]Incompatible types in predicate.]


The table has got more than 100000 rows of data...

can anybody help me with this...its urgent...

Thanks in advance...


0
Gopsolution
Asked:
Gopsolution
  • 3
  • 2
  • 2
  • +1
1 Solution
 
MannaraprayilCommented:
Please try this

select * from openquery(SERVER,'select * from table where date_time = ''4/23/2005'' ')
0
 
JulianvaCommented:


select * from openquery(SERVER,"select * from table where date_time = '2005-04-23' " )

 
0
 
GopsolutionAuthor Commented:
Its not working....i am getting the following error

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'select * from result where date_time = '2005-04-23''.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
JulianvaCommented:
double qoutes before select

select * from openquery(SERVER,"select * from table where date_time = '2005-04-23' " )
0
 
MannaraprayilCommented:
Just tell us what error u r getting while executing this..
select * from openquery(SERVER,'select * from table where date_time = ''2005-04-23'' ')
0
 
MannaraprayilCommented:
you can try CONVERT function....
select * from openquery(SERVER,'select * from table where
CONVERT(VARCHAR(10),date_time,101) = ''04/23/2005'' ')

remember its not double quotes before and after 04/23/2005...its two single quotes put together.....

btw you should not have opened a new thread for this.....
0
 
dvsameerkumarCommented:
select * from openquery(SERVER,'select * from table where date_time = ''2005-04-23 00:00:00'' ')
0
 
dvsameerkumarCommented:
this worked for me
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now