generating Passowrd of length 8 randomly in SQL Server

Posted by Bandi under Sql Server category on | Points: 40 | Views : 898
declare @password varchar(8)
set @password=''

select @password=@password+char(n) from
select top 8 number as n from master..spt_values
where type='p' and number between 48 and 122
order by newid()
) as t
select @password

Here, The logic is taking top 8 numbers randomly and then converting randomly generated number to euivalent character code by using CHAR(n) function...

Comments or Responses

Login to post response