I have a query that I am trying to run against an oracle database. The oracle is a linked server and so I am using openquery to do this. The issue resolves around the date in the where clause.
Here is the statement:
SET @TSQL = 'SELECT SEQ FROM OPENQUERY([LINKED_SERVER], ''SELECT SEQ FROM SCHEMA.TABLE WHERE A_NUM BETWEEN 500 AND 599 AND A_DATE = to_date(''02/26/2015'',''mm/dd/yyyy'')'')'
If I do a print on that variable and take it and run it in TOAD it works fine. When I run it in SSMS I get this error:
Incorrect syntax near '02'.
If I take out the last line and run it in SSMS it returns records just fine. Am I just missing something?