A script that creates a global temporary table of random numbers : Temporary Table « Table « SQL Server / T-SQL Tutorial






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








3.7.Temporary Table
3.7.1.Temporary Tables
3.7.2.Local temporary Table
3.7.3.Using a Temporary Table to Communicate with an EXEC()
3.7.4.A script that creates a global temporary table of random numbers
3.7.5.A script that uses a local temporary table instead of a derived table
3.7.6.SELECT INTO a temporary table
3.7.7.Creating a Table with Duplicate Rows
3.7.8.A global temporary table's name begins with ##.
3.7.9.Creating a Local Temporary Table with a SELECT INTO