Generating Random Strings of Characters in SQL

The following Transact SQL procedure can be used to generate a random string of characters. As such it can be used to for example generate a default password for a user. The specific characters that are used to generate the string can be specified, so it can be customised (e.g. to only create passwords of digits or lower cased letters). The length of the generated random string can also be specified.

It is recommended that this SQL procedure be used as a stored procedure.

Using as a Stored Procedure

The following stored procedure creates a random string of characters of a length specified by the parameter @Length:

Share this:

Like this:

Related

I love your blog.. very nice colors & theme.
Did you make this website yourself or did you hire someone to do
it for you? Plz respond as I’m looking to construct my own blog and would like to know where u got this from. cheers