I am trying to find a value and then use this within another statement within the same SQL stored procedure . However I am lost with the syntax (if this is even possible).
Below I have posted my code as this will be the easiest way to explain fully.
CREATE PROCEDURE FindRuidForUser
@Email nvarchar (160),
@RUId int,
@DeskLocation nvarchar(160),
@ExtraInformation nvarchar(160),
@PrimaryWorkStation nvarchar(160),
@Date datetime
AS
SELECT RUId
FROM RegisteredUsers
WHERE Email = @Email
RUId = @RUId
Then
INSERT INTO diffrenttable (RUId, PrimaryWorkStation, DeskLocation, ExtraInformation, TimeCreated)
VALUES (@RUId, @PrimaryWorkStation, @DeskLocation, @ExtraInformation, @TimeCreated)
I would first like to find the RUId and then I would like to insert this into a separate table along with the rest of the variables I will be using.
Any help is greatly appreciated.
Thank you !