Here is one option that gives you very strong random passwords. It uses the numbers table, but not so simple.
declare @chars char(62), @bytes binary(8) set @chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' set @bytes = CRYPT_GEN_RANDOM(8) select SUBSTRING(@chars, (SUBSTRING(@bytes, n.Number, 1) % LEN(@chars)) + 1, 1) from dbo.Numbers n where n.Number between 1 and LEN(@bytes) FOR XML PATH ('')
source share