AnsweredAssumed Answered

Incorrect syntax near '@P0' SQL Connector

Question asked by stephenp on Jun 13, 2017

I am getting the following error when running an open sql query.


Errors occurred while building or executing SQL statement: Incorrect syntax near '@P0'.; Caused by: Incorrect syntax near '@P0'


The query runs fine if i dont use any parameters, but as soon as i add a parameter i get the about error.


Example sql script below:


select id
,dateadd(ss,[crt-tim],cast([crt-dat] as datetime)) as CrtDteTim
,dateadd(ss,[crt-tim],cast([crt-dat] as datetime)) as UpdDteTim
from openquery(?,
'select * from pub.table where "crt-dat" >= '?'
order by "page-no" ')
where dateadd(ss,[crt-tim],cast([crt-dat] as datetime)) > ?


Any ideas why we are getting this error?