I want to generate access token if username and password will match in users table. But how can I use previous returned value to next insert query? I have marked missing value with ###I don't know###.
CREATE PROCEDURE [dbo].[GetAccessToken]
@userId varchar(50),
@password varchar(50)
AS
SELECT Id
FROM Users
WHERE UserId = @userId AND Password = @password
IF @@ROWCOUNT != 0
BEGIN
SET @token = NEWID();
INSERT INTO AccessTokens (Token, UserId)
VALUES(CONVERT(varchar(255), @token), ###I Don't Know###)
END
RETURN 0
END
Please help me. Thanks, in advance.