title: Execute a literal string as a SQL statement - placement of single quotes
body: <p>I have the following SQL string pulls data from a ODBC Progress Database via a linked server. <strong>This query works fine.</strong> </p>
  
  <pre><code>SELECT * 
  INTO [TABLE] 
  FROM 
  OPENQUERY
  (
  "ODBC DRIVER",
  'SELECT CAST(SCHEMA."AB_ACCESSIBILITY"."ACCESS_CODE" AS VARCHAR(20)) AS "ACCESS-CODE"
  ,CAST(SCHEMA."AB_ACCESSIBILITY"."DESCRIPTION" AS VARCHAR(60)) AS "DESCRIPTION"
  ,CAST(SCHEMA."AB_ACCESSIBILITY"."ORG_CODE" AS VARCHAR(16)) AS "ORG_CODE"
  ,CAST(SCHEMA."AB_ACCESSIBILITY"."POINTS" AS INT) AS "POINTS" 
  FROM SCHEMA."AB_ACCESSIBILITY" with (nolock)'
  )
  </code></pre>
  
  <p>However, I would like to convert this to a <strong>literal string</strong> so that I can execute this from a stored procedure using <code>exec sp_executesql</code>. </p>
  
  <p>However, I'm having trouble with correct placement of apostrophes so that <code>exec sp_executesql</code> can read it as a properly formed SQL statement.</p>
  
  <p>Could someone please show me where to add additional apostrophes to the above statement so that it will work with exec sp_excutesql?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edits for clarity:</strong></p>
  
  <ol>
  <li><p><code>With (nolock)</code> is fine for the above</p></li>
  <li><p>The purpose of the above is to loop over a number of SQL statements in a list to import data from a Progress DB.</p></li>
  </ol>