/*
Question
How to generate 10 thousand numbers, insert them to table t (COL varchar (20), and the numbers cannot be repeated. They can only be retrieved from 26 lower-case letters.
*/
-- 1. Current statement
Select 'A' As Col
Into # T
Union
Select 'B' Union
Select 'C' Union
Select 'D' Union
Select 'E' Union
Select 'F' Union
Select 'G' Union
Select 'H' Union
Select 'I' Union
Select 'J' Union
Select 'K' Union
Select 'L' Union
Select 'M' Union
Select 'N' Union
Select 'O' Union
Select 'P' Union
Select 'Q' Union
Select 'R' Union
Select 'S' Union
Select 'T' Union
Select 'U' Union
Select 'V' Union
Select 'W' Union
Select 'X' Union
Select 'Y' Union
Select 'Z'
Insert Into T
Select Top 10000 a. Col + B. Col + C. Col From # T a, # t B, # T c
Drop Table # T
--------------------------------------------------------------
-- 2. View varchar (20), think of newid (), and then perform some string processing.
Insert Into T
Select Top 10000
Replace (Replace ( Replace ( Replace ( Replace ( Replace ( Replace ( Replace ( Replace ( Replace (Lower ( Left ( Replace (Newid (),
'-',''), 20 )),
' 0 ', 'A '),1 ,
'B '), 2 , 'C '), 3 ,
'D '), 4 , 'E '), 5 ,
'F '), 6 , 'G '),7 , 'H '), 8 , 'I '),
9 , 'J ') As Col
From SYS. all_columns,
SYS. all_objects