password_random

Definition

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:

For information on setting global password complexity checks, see the 15.0.2 New Feature Guide, Chapter 25.

Syntax

password_random ([pwdlen])

Parameters

pwdlen – 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.

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

Examples

Example 1 The password complexity checks stored in the server are:

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

Using password_random() the following password is generated:

select password_random()
----------------
wS5y9jP7hi

Example 2 The password complexity checks stored in the server are:

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 Update 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 Generate a random password and use 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'