Search code examples
sql-serveroracle-databaselinked-serveropenquery

LinkedServer Openquery is throwing this error : ORA-00923: FROM keyword not found where expected


I am running below query in SQL Server 2012 against a linked server and i am getting below error. Am I using an incorrect keyword/function or missing any syntex. The query is running fine when I am running without openquery

ORA-00923: FROM keyword not found where expected

The query is below :

select * from openquery(LinkedServerName,
'select t.TRANSACTION,t.PARTNER,t.DATE

from

(select st.TRANSACTION,st.PARTNER,st.DATE
,RowNum = ROW_NUMBER() over(partition by st.TRANSACTION order by st.DATE desc)
from tbltransactions st) t where t.RowNum = 1')

Solution

  • Please try

    select * from openquery(LinkedServerName,
    'select t.TRANSACTION,t.PARTNER,t.DATE
    
    from
    
    (select st.TRANSACTION,st.PARTNER,st.DATE
    ,ROW_NUMBER() over(partition by st.TRANSACTION order by st.DATE desc) as RowNum
    from tbltransactions st) t where t.RowNum = 1')