I am not completely sure how to articulate this, so please be sure to ask me to clarify something if it isn’t clear. Here is what I want to do:
ALTER PROCEDURE UpdateUserProfiles
@userId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON;
SET oldUser = (SELECT TOP 1
FirstName
FROM OldUsers WHERE UserId = @userId);
UPDATE NewUsers
SET FirstName = oldUser.FirstName
WHERE Id = @userId;
END
GO
Now obviously this does not work, but how do I go about using a row inside my SP? Thank you.
Does this help you ?
Here is a variation of Adrians script that can update all rows at once: