Use Table Variables as a table : Table Variable « Transact SQL « SQL Server / T-SQL Tutorial






6> Declare @MyTableVar table
7>      (Id int primary key,
8>      Lookup varchar(15))
9>
10> Insert @MyTableVar values (1, '1Q2000')
11> Insert @MyTableVar values (2, '2Q2000')
12> Insert @MyTableVar values (3, '3Q2000')
13>
14> Select * from @MyTableVar
15> Go

(1 rows affected)

(1 rows affected)

(1 rows affected)
Id          Lookup
----------- ---------------
          1 1Q2000
          2 2Q2000
          3 3Q2000

(3 rows affected)
1>
2>








20.5.Table Variable
20.5.1.The syntax of the DECLARE statement for a table variable
20.5.2.Inline Table-Valued Functions
20.5.3.Insert into a table variable
20.5.4.Use Table Variables as a table
20.5.5.Creating a Table Variable to Hold a Temporary Result Set