how to create view random string sessionid and otp

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);

  

Post a Comment

0 Comments