Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with linked server Sql query

Status
Not open for further replies.

swenri

Programmer
Jul 4, 2006
30
US
I created a linked server using Microsoft OLE DB Provider for Oracle. I created an inner join query in Sql Server Management Studio.

The inner join query works without the date selection parameter but, when I use the date selection parameter
it throws an error Msg 102, Level 15, State 1, Line 8
Incorrect syntax near '01'.


AND (MASTER50_ENT.ORDERS.ORDER_DTM) BETWEEN to_date('01-JAN-2009', 'dd-MON-YYYY') AND to_date('31-JAN-2009','dd-MON-YYYY' ' ) AS a


I’ve tried every possible way to solve it by changing the date format but, nothing seems to work.



SELECT a.* FROM OPENQUERY(TESTORALINK,'SELECT MASTER50_ENT.ORDERS.ORDER_ID, _

MASTER50_ENT.ACCOUNT.EXTERNAL_ACCOUNT_NUMBER, _

MASTER50_ENT.CONTACT.COMPANY, _

MASTER50_ENT.ACCOUNT.COUNTRY_CD

FROM MASTER50_ENT.ACCOUNT,MASTER50_ENT.ORDERS,MASTER50_ENT.CONTACT

WHERE MASTER50_ENT.ORDERS.ACCOUNT_ID = MASTER50_ENT.ACCOUNT.ACCOUNT_ID

AND MASTER50_ENT.ACCOUNT.CONTACT_ID = MASTER50_ENT.CONTACT.CONTACT_ID

AND (MASTER50_ENT.ORDERS.ORDER_DTM) BETWEEN to_date('01-JAN-2009', 'dd-MON-YYYY') AND to_date('31-JAN-2009','ddMONYYYY' ' ) AS a



Also, another question is how create a report in SSRS 2005 using the same linked server ?


Thank you for the help ….

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top