password_random

Description

Generates a pseudorandom password that satisfies the global password complexity checks defined on Adaptive Server. “Pseudorandom” indicates that Adaptive Server is simulating random-like numbers, since no computer generates truly random numbers. The complexity checks are:

Syntax

password_random ([pwdlen])

Parameters

pwdlen

is an integer that specifies the length of the random password. If you omit pwdlen, Adaptive Server generates a password with a length determined by the 'minimum password length' global option, for which the default value is 6.

Examples

Example 1

Shows the password complexity checks stored in the server:

minimum password length:           10
min digits in password:             2
min alpha in password:              4
min upper char in password:         1
min special char in password:      -1
min lower char in password:         1

select password_random()
----------------------
6pY5l6UT]Q

Example 2

Shows password complexity checks stored in the server:

minimum password length:                  15
minimum digits in password:                4
minimum alpha in password:                 4
minimum upper-case characters in password: 1
minimum lower-case characters in password: 2
minimum special characters in password:    4

select password_random(25)
-----------------
S/03iuX[ISi:Y=?8f.[eH%P51

Example 3

Updates the password column with random passwords for all employees whose name begins with “A”:

update employee
set password = password_random()
where name like 'A%'

Example 4

Generates a random password and uses it to create a login account for user “anewman”.

declare @password varchar(10)
select @password =               password_random(10)
exec sp_addlogin 'jdoe', @password

Example 5

Enclose the random password generated in single or double quotes if using it directly:

select @password = password_random(11)
-----------
%k55Mmf/2U2

sp_adlogin 'jdoe','%k55Mmf/2U2'

Usage

The passwords generated by password_random() are pseudorandom; to generate truly random passwords, use a stronger random generator.