title: Incorrect syntax near 'UPDATE'
body: <p>I have 2 tables X and Y.</p>
  <p>X is like</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>D100_PTRSORID</th>
  <th>D100_LIB17</th>
  <th>D100_LIB18</th>
  <th>D100_LIB19</th>
  <th>....</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>10</td>
  <td>15000</td>
  <td>2000</td>
  <td>75000</td>
  <td>...</td>
  </tr>
  <tr>
  <td>11</td>
  <td>12500</td>
  <td>2500</td>
  <td>7000</td>
  <td>...</td>
  </tr>
  <tr>
  <td>12</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  </tr>
  <tr>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>The amounts in the fields <code>D100_LIBXX</code> are not correct. I would like to update these amounts thanks to table Y, which is like</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>GAD_PTRSORID</th>
  <th>GAD_CODE</th>
  <th>GAD_CAPITAL</th>
  <th>...</th>
  <th>....</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>10</td>
  <td>201**</td>
  <td>11000</td>
  <td>...</td>
  <td>...</td>
  </tr>
  <tr>
  <td>10</td>
  <td>202**</td>
  <td>1500</td>
  <td>...</td>
  <td>...</td>
  </tr>
  <tr>
  <td>10</td>
  <td>203**</td>
  <td>8500</td>
  <td>...</td>
  <td>...</td>
  </tr>
  <tr>
  <td>11</td>
  <td>201**</td>
  <td>12500</td>
  <td>...</td>
  <td>...</td>
  </tr>
  <tr>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><code>D100_LIB17</code> is related to <code>GAD_CODE</code> = '201**'</p>
  <p><code>D100_LIB18</code> is related to <code>GAD_CODE</code> = '202**'</p>
  <p><code>D100_LIB19</code> is related to <code>GAD_CODE</code> = '203**'</p>
  <p>I started to write this following script for updating the data but I have an error at the &quot;UPDATE&quot; level (underlined in red) with error message <strong>Incorrect syntax near 'UPDATE'. Expected end-of-input -or- [...]</strong></p>
  <pre><code>SELECT * FROM X
  
  UPDATE Xx 
  SET Xx.D100_LIB17=Yy.GAD_CAPITAL
  FROM X Xx
  INNER JOIN Y Yy 
  ON Xx.D100_PTRSORID = Yy.GAD_PTRSORID and Yy.GAD_CODE = '201**'
  
  SELECT * FROM X 
  </code></pre>