Mega Code Archive

 
Categories / MSSQL Tutorial / Table
 

A script that creates a global temporary table of random numbers

6> 7> CREATE TABLE ##RandomSSNs 8> (SSN_ID int IDENTITY, 9>  SSN char(9) DEFAULT  LEFT(CAST(CAST(CEILING(RAND()*10000000000)AS bigint)AS varchar),9)) 10> GO 1> 2> INSERT ##RandomSSNs VALUES (DEFAULT) 3> INSERT ##RandomSSNs VALUES (DEFAULT) 4> GO (1 rows affected) (1 rows affected) 1> 2> SELECT * FROM ##RandomSSNs 3> GO SSN_ID      SSN ----------- ---------           1 515035498           2 432526378 (2 rows affected) 1> 2> drop table ##RandomSSNs; 3> GO