Passing variables to an Oracle Open query in SQL 2005

Hi Experts I have a Linked SQL 2005 server to an Oracle db

I want to query a table by a date field held in SQL server, can I do the following or do I need to create my SQL syntax before passing it the open query

DECLARE @RunDate datetime

SET @DateTime = (select RunDate from tblParameter)


SELECT * FROM OPENQUERY
(ORACLE_CONNECTION,'
SELECT * FROM ORACLE.MYTABLE WHERE ENTRY_DATE >=
TO_DATE(''' + @DateTime +''',''YYYY-MM-DD HH24:MI:SS'')'
')
MrDavidThornAsked:
Who is Participating?
 
sdstuberConnect With a Mentor Commented:
looks like you have an extra quote after your query


sorry should have provided link  http://www.experts-exchange.com/Q_27391110.html
0
 
sdstuberCommented:
should be able to, easiest way to verify is to try it.


please revisit your prior question
0
 
MrDavidThornAuthor Commented:
I get an error message Incorrect syntax near '+'.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
MrDavidThornAuthor Commented:
I have found this guide thanks anyhow
0
 
MrDavidThornAuthor Commented:
0
 
sdstuberCommented:
yes, that's what you've got,  just make sure your quotes are correct,  glad I could help.


please revisit the previous question noted above
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.