title: Passing concat query parameters to SQL OPENQUERY
body: <p>Due to the constraints within the workplace I have to use a local stored procedure to call another remote stored proc on a linked sql server, however the problem lies in passing a necessary parameter to the remote stored proc.</p>
  
  <p>This is the query I constructed:</p>
  
  <pre><code>select *
  from OPENQUERY([REMOTE_SRVR],'exec db.dbo.dwStoredProc_sp ''@id''')
  </code></pre>
  
  <p>In order to pass <code>@id</code> to the remote stored proc I understand I could concatenate the above as a string and then use <code>exec</code></p>
  
  <p>Something along the lines of:</p>
  
  <pre><code>set @query = 'select * from OPENQUERY([REMOTE_SRVR], ''EXEC db.dbo.dwStoredProc_sp '' @id '''''
  exec(@query)
  </code></pre>
  
  <p>I cannot get the local stored proc to successfully call the other. The single quote mess doesn't help!</p>
  
  <p>I get the error: <code>Could not find stored procedure 's'</code></p>