Procedure to create random code for user on every page load
Create PROCEDURE Getstudentname
(
@studentid INT,
@studentname VARCHAR(20) OUT
)
AS
Declare @Counter INT
Set @Counter = 1
While(@Counter <= 10)
BEGIN
SELECT @studentname= SUBSTRING(Firstname,1,3)+ convert (varchar(30),FLOOR(RAND() * 100)) +substring(Lastname,1,3) FROM tbl_Students WHERE studentid=@studentid
Set @Counter = @Counter + 1
END
Declare @Studentname as nvarchar(200) -- Declaring the variable to collect the Studentname
Execute Getstudentname 2 , @Studentname output
select @Studentname
-------------------------------------------------------------------------------
Output:-
------> On first click
Pan75Kum
-------> On next click
Pan18Kum
(Digit will change randomly)