Last active
July 13, 2016 21:19
-
-
Save keith9820/c6b214357fcf71552757 to your computer and use it in GitHub Desktop.
Generate a random password in T-SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @idx as int | |
declare @randomPwd as nvarchar(64) | |
declare @rnd as float | |
select @idx = 0 | |
select @randomPwd = N'' | |
select @rnd = rand((@@CPU_BUSY % 100) + ((@@IDLE % 100) * 100) + | |
(DATEPART(ss, GETDATE()) * 10000) + ((cast(DATEPART(ms, GETDATE()) as int) % 100) * 1000000)) | |
while @idx < 64 | |
begin | |
select @randomPwd = @randomPwd + char((cast((@rnd * 83) as int) + 43)) | |
select @idx = @idx + 1 | |
select @rnd = rand() | |
end | |
select @randomPwd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment