There can be several ways to generate a random password. Assume that your password should contain alphabets, numbers and some special characters. The following is one of the ways.
declare @password varchar(20)
SELECT ”+password FROM
select top 8 char(number) as password from master..spt_values
where type=‘p’ and number between 48 and 122
order by newid()
) as t
FOR XML PATH(”)
) as password
The above creates some random password with 8 characters in length. If you want to change the length, change the number in the TOP clause.
The password I got running this code is T5:DZ?ow