title: Update OpenQuery with parameters
body: <h3>UPDATE OPENQUERY Help</h3>
  <blockquote>I am trying to update an Oracle 11 table via a linked server in SQL, now the linked server and select statements all appear correct and I think I am very close to cracking this, but I am having issues with the update.  The other OPENQUERY commands work correctly e.g.  
  </blockquote>
  <p><em><code>SELECT * FROM OPENQUERY(LinkedServer, 'SELECT PL.place_id, PL.phy_svc_grp_b FROM OU_DBA.REQUEST RT INNER JOIN OU_DBA.PLACE PL ON RT.place_id = PL.place_id WHERE (RT.phy_svc_grp_b IS NULL) AND        (PL.phy_svc_grp_b IS NOT NULL)')</code></em></p>
  <p>This is performing as expected; this information is then placed into a temporary table and using a <code>WHILE</code> I create an update openquery;</p>
  <pre><code>SET @TEMP_COUNT = (SELECT COUNT(*) FROM #MissingRegions)
              WHILE @TEMP_INDEX &lt; @TEMP_COUNT +1
                  BEGIN
                  -----Clear out the SQL String
                  SET @SQL_STRING = ''
  
                  -----Assign the Place ID.
                  SET @PLACE_ID = (SELECT PLACE_ID FROM #MissingRegions WHERE ID =@TEMP_INDEX)
  
                  -----Assign the Region.
                  SET @REGION = (SELECT GROUP_B FROM #MissingRegions WHERE ID =@TEMP_INDEX)
  
                  SET     @SQL_STRING ='UPDATE OPENQUERY(LinkedServer, ''SELECT PHY_SVC_GRP_B FROM [OU_DBA].[REQUEST] WHERE PLACE_ID =''' + @PLACE_ID + ''')' + ' SET PHY_SVC_GRP_B = ''' + @REGION + ''''
                  PRINT   @SQL_STRING
                  EXEC        (@SQL_STRING)
  
              ----Increment the index value by 1
                  SET @TEMP_INDEX = @TEMP_INDEX +1
          END
  </code></pre>
  <p>The output from the Print command returns the following;<em></p>
  <p><code>UPDATE OPENQUERY(LinkedServer, 'SELECT PHY_SVC_GRP_B FROM [OU_DBA].[REQUEST] WHERE PLACE_ID ='ES5159') SET PHY_SVC_GRP_B = '1000'</code></em></p>
  <p>But I keep getting the following error for each record i try to update;
  <em>Msg 102, Level 15, State 1, Line 1
  Incorrect syntax near 'ES5159'.
  Msg 105, Level 15, State 1, Line 1
  Unclosed quotation mark after the character string ''.</em></p>
  <p>If anyone could possibly suggest where I may be going wrong and provide a solution for this I would be extremely grateful.</p>