?
Solved

Passing variables to an Oracle Open query in SQL 2005

Posted on 2011-10-11
6
Medium Priority
?
320 Views
Last Modified: 2012-05-12
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'')'
')
0
Comment
Question by:MrDavidThorn
  • 3
  • 3
6 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 36950550
should be able to, easiest way to verify is to try it.


please revisit your prior question
0
 

Author Comment

by:MrDavidThorn
ID: 36950564
I get an error message Incorrect syntax near '+'.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 36950591
looks like you have an extra quote after your query


sorry should have provided link  http://www.experts-exchange.com/Q_27391110.html
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:MrDavidThorn
ID: 36950685
I have found this guide thanks anyhow
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 36950710
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question