title: Set A Variable From A Table
body: <p>If I want to set a variable to a field in a table I normally use something like</p>
  
  <pre><code>SELECT @UserIdToUpdate = userId FROM #NewUsers
  </code></pre>
  
  <p>In this case there will be multiple results and I just want the first one so I tried this but it fails and says invalid syntax top</p>
  
  <pre><code>SELECT @UserIdToUpdate = TOP 1 UserId FROM #NewUsers
  </code></pre>
  
  <p>If this is this case can I just usethe first example without the top? I assume it will just take the first record? I know it seems like on odd thing to do but the command is in a loop so it will select a record, do something with it, delete it then select the next one.</p>