How To Create Random String And OTP Using View In SQL Server

Hello Friends, In this article I will show you how to create random string and OTP using view in SQL server.

Step 1 :- Create Below View In SQL Server.

CREATE VIEW VW_CREATERANDOMSTRING
AS
SELECT  
 SESSIONID = (SELECT
   C1 AS [text()]
  FROM (SELECT TOP (50)
    C1
   FROM (VALUES('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),
   ('K'), ('L'), ('M'), ('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),
   ('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'), ('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),
   ('K'), ('L'), ('M'), ('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),
   ('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'), ('0'), ('1'), ('2'), ('3'),
   ('4'), ('5'), ('6'), ('7'), ('8'), ('9')
   ) AS T1 (C1)
   ORDER BY ABS(CHECKSUM(NEWID()))) AS T2
  FOR XML PATH (''))
,OTP = LEFT(CAST(RAND()*1000000000+999999 AS INT),6);

Step 2 :- Let’s See Below Output.

Please give your valuable feedback and if you any consort regarding this article, please let me know

Also, Check How To Find all WI-FI Passwords Saved On Your Computer

Submit a Comment

Your email address will not be published.

Subscribe

Select Categories