Best WAY :
select LOWER(left(newid(),8) ) + LOWER(right(newid(),8) )
or just
select LOWER(left(newid(),8) )
OR
select left(newid(),8)
Second Way:
CREATE PROC spGeneratePassword
AS
DECLARE @RandomNumber float
DECLARE @RandomInteger int
DECLARE @MaxValue int
DECLARE @MinValue int
DECLARE @i AS INT
DECLARE @Password AS VARCHAR(10)
SET @Password = ''
SET @MaxValue = 26
SET @MinValue = 1
SET @i = 3
WHILE(@i>0)
BEGIN
SET @i = @i -1
select @RandomNumber = RAND()
set @RandomInteger = ((@MaxValue + 1) - @MinValue) * @RandomNumber + @MinValue
SET @Password = @Password + CHAR(96 + @RandomInteger)
END
SET @MaxValue = 9
SET @MinValue = 1
SET @i = 2
WHILE(@i>0)
BEGIN
SET @i = @i -1
select @RandomNumber = RAND()
set @RandomInteger = ((@MaxValue + 1) - @MinValue) * @RandomNumber + @MinValue
SET @Password = @Password + CHAR(48 + @RandomInteger)
END
SET @MaxValue = 26
SET @MinValue = 1
SET @i = 3
WHILE(@i>0)
BEGIN
SET @i = @i -1
select @RandomNumber = RAND()
set @RandomInteger = ((@MaxValue + 1) - @MinValue) * @RandomNumber + @MinValue
SET @Password = @Password + CHAR(96 + @RandomInteger)
END
select @Password AS 'Password'
Third way ( just generate 150 password ):
INSERT INTO
dbo.attendee_users (password)
SELECT a.A + b.B + c.C + d.D AS Password
FROM
(SELECT 'a' AS A
UNION
SELECT 'r'
UNION
SELECT 'i') a
CROSS JOIN
(SELECT '5' AS B
UNION
SELECT '2'
UNION
SELECT '19'
UNION
SELECT '4'
UNION
SELECT '87a3') b
CROSS JOIN
(SELECT 'vgh' AS C
UNION
SELECT '8R7y') c
CROSS JOIN
(SELECT '6' AS D
UNION
SELECT '7'
UNION
SELECT '8'
UNION
SELECT '9'
UNION
SELECT '1') d
No comments:
Post a Comment