Sunday, September 19, 2010

Table variable indexes

Two types of indexes may be specified on a table variable - primary key (clustered) and unique. However, they need to be included in the table variable definition.

DECLARE @test TABLE
(
a INT PRIMARY KEY,
b varchar(50),
UNIQUE (b)
)


Generally, temp tables perform better in situations where an index is needed.