Skip to content

Instantly share code, notes, and snippets.

@davipviana
Last active June 11, 2020 12:13
Show Gist options
  • Save davipviana/db76434e82b5037472263a5e4be79ae6 to your computer and use it in GitHub Desktop.
Save davipviana/db76434e82b5037472263a5e4be79ae6 to your computer and use it in GitHub Desktop.
SQL script to generate pwd
DECLARE @char CHAR = ''
DECLARE @charI INT = 0
DECLARE @password VARCHAR(100) = ''
DECLARE @len INT = 16 -- Length of Password
WHILE @len > 0
BEGIN
SET @charI = ROUND(RAND()*100,0)
SET @char = CHAR(@charI)
IF @charI >= 48 AND @charI <= 122 AND @charI <> 59 AND @charI <> 61 AND @charI <> 92
BEGIN
SET @password += @char
SET @len = @len - 1
END
END
SELECT @password [Password]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment