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.
I have drastically simplified my SQL below to illustrate my issue. Here's what I want to achieve :
DECLARE @UserID INT
SELECT TOP(1) @UserID = UserID, UserName, email, (#Loads of other columns#) FROM Users
UPDATE Logins SET LoggedIn = 1 WHERE UserID = @UserID
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.
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)
Any suggestions guys ? Thanks, Scott