|
|
|
This procedure generates random passwords using RAND() function. It can be configured to generate a simple or a complex password. You can also customize the length of the password generated. Complex passwords will include upper and lower case letters, numbers and special characters. See the code to realize how useful the RAND() function is! When you choose to generate a simple password (default behavior), SPECIAL CARE is taken to generate meaningful/easy to remember passwords. |
Click here to copy the following block | CREATE PROC random_password ( @len int = 8, @password_type char(7) = 'simple'
) AS
BEGIN DECLARE @password varchar(25), @type tinyint, @bitmap char(6) SET @password='' SET @bitmap = 'uaeioy'
WHILE @len > 0 BEGIN IF @password_type = 'simple' BEGIN IF (@len%2) = 0 SET @password = @password + SUBSTRING(@bitmap,CONVERT(int,ROUND(1 + (RAND() * (5)),0)),1) ELSE SET @password = @password + CHAR(ROUND(97 + (RAND() * (25)),0)) END ELSE BEGIN SET @type = ROUND(1 + (RAND() * (3)),0)
IF @type = 1 SET @password = @password + CHAR(ROUND(97 + (RAND() * (25)),0)) ELSE IF @type = 2 SET @password = @password + CHAR(ROUND(65 + (RAND() * (25)),0)) ELSE IF @type = 3 SET @password = @password + CHAR(ROUND(48 + (RAND() * (9)),0)) ELSE IF @type = 4 SET @password = @password + CHAR(ROUND(33 + (RAND() * (13)),0)) END
SET @len = @len - 1 END
SELECT @password
END |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|