Generating Random Password in SQL Server
Hello everyone,
In this article, I will provide information about creating a random password in SQL Server.
In SQL Server, we may want to create a random password in some cases.
You can easily do this with the help of the code below.
SELECT
(
SELECT '' + Psswrd
FROM
(
SELECT TOP 10
--You can create a password at any step by changing this part.
CHAR(Number) AS Psswrd
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS Number
FROM sys.syscolumns
) AS t
WHERE Number
BETWEEN 48 AND 122
ORDER BY NEWID()
) AS t
FOR XML PATH('')
) AS Psswrd;
When you run the code, you will get a result like the one below.
As you can see, a random password has been created.
Good luck to everyone in business and life.