-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsp_GenerateRandomKey.sql
More file actions
44 lines (40 loc) · 2.01 KB
/
sp_GenerateRandomKey.sql
File metadata and controls
44 lines (40 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
CREATE PROCEDURE [dbo].[sp_GenerateRandomKey] @randomKey char(128) output
AS
BEGIN
DECLARE @s char(128);
SET @s = (
SELECT
c1 AS [text()]
FROM
(
SELECT TOP (128) c1
FROM
(
VALUES
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),('K'), ('L'), ('M'),
('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'),
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),('K'), ('L'), ('M'),
('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'),
('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h'), ('i'), ('j'), ('k'), ('l'), ('m'),
('n'), ('o'), ('p'), ('q'), ('r'), ('s'), ('t'), ('u'), ('v'), ('w'), ('x'), ('y'), ('z'),
('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h'), ('i'), ('j'), ('k'), ('l'), ('m'),
('n'), ('o'), ('p'), ('q'), ('r'), ('s'), ('t'), ('u'), ('v'), ('w'), ('x'), ('y'), ('z'),
('0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9'),
('0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9'),
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),('K'), ('L'), ('M'),
('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'),
('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), ('H'), ('I'), ('J'),('K'), ('L'), ('M'),
('N'), ('O'), ('P'), ('Q'), ('R'), ('S'), ('T'),('U'), ('V'), ('W'), ('X'), ('Y'), ('Z'),
('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h'), ('i'), ('j'), ('k'), ('l'), ('m'),
('n'), ('o'), ('p'), ('q'), ('r'), ('s'), ('t'), ('u'), ('v'), ('w'), ('x'), ('y'), ('z'),
('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h'), ('i'), ('j'), ('k'), ('l'), ('m'),
('n'), ('o'), ('p'), ('q'), ('r'), ('s'), ('t'), ('u'), ('v'), ('w'), ('x'), ('y'), ('z'),
('0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9'),
('0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), ('8'), ('9')
) AS T1(c1)
ORDER BY ABS(CHECKSUM(NEWID()))
) AS T2
FOR XML PATH('')
);
Set @randomKey = @s;
END;