[dba-SQLServer]Random password generator?

stuart at lexacorp.com.pg stuart at lexacorp.com.pg
Mon May 19 19:42:09 CDT 2003


On 19 May 2003 at 10:36, Joe Rojas wrote:

> Hi All,
> 
> Does anyone have any routines that I could put in a stored procedure in SS7
> that will generate random alpha-numeric passwords?
> I would like to be able to also specify what length of a password that I
> want.
> 
> If you don't have one, maybe someone has a idea of how to do this?
> 
> Thank in advance!
> 

CREATE PROCEDURE CREATE_PASSWORD
@maxlength int
 AS

declare @password nvarchar(20)
declare @counter int
declare @charint int
declare @chars nvarchar(62)

set @counter = 0
set @chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
SET @PASSWORD = ''
WHILE @counter < @maxlength
BEGIN   
    	SET @counter = @counter + 1
        set @charint = rand()*62 +1
        set @password = @password + SUBSTRING(@chars, at charint,1)
END
select @password
-- 
Lexacorp Ltd
Information Technology Consultancy, Application Development






More information about the dba-SQLServer mailing list