trouble writing select with an OPENQUERY

  • My select statement is as follows:

    SELECT L.[DATE],E.* FROM SAFETYLOGS2.DBO.LOGS AS L INNER JOIN OPENQUERY(UNIDATA,'SELECT ID,NAME1,TERMNUM FROM CONTRACTOR_MASTER WHERE CANCEL_DATE = "" AND CONT_TYPE = 1;') As E on L.contractornum = E.ID where date between @firstdate and @seconddate and logs='nologs' AND E.TERMNUM = @termnum order by L.contractornum,L.date

    This works but what I want to do is move the AND E.TERMNUM = @termnum to inside the open query statement. But if I put single quotes to get the @termnum it tells me it does not like the + sign. I tried putting double quotes around it and the query does not return results. Is there a way to pass the parameter to an openquery?

    Matt

  • Only by building sql string for the whole statement and using sp_executesql

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply