title: Setting a variable to the result of a select query SQL server 2012
body: <p>I am trying to find the most economical way of achieving a way to return the data I want and also updating another table within the same Stored Procedure.</p>
  
  <p>I have drastically simplified my SQL below to illustrate my issue.
  Here's what I want to achieve :</p>
  
  <pre><code>DECLARE @UserID INT
  SELECT TOP(1) @UserID = UserID, UserName, email, (#Loads of other columns#) FROM Users
  UPDATE Logins SET LoggedIn = 1 WHERE UserID = @UserID
  </code></pre>
  
  <p>I understand I could do this by making sure that all returned columns are assigned to a local variable, but there are too many to be an efficient SPROC.</p>
  
  <p>I don't want to have to do the SELECT statement twice (once to return the data and once to set the variable, ready for the update statement)</p>
  
  <p>Any suggestions guys ?
  Thanks,
  Scott</p>