views:

1881

answers:

1

Can you create a index on a table variable in SQL Server 2000?

i.e.

DECLARE @TEMPTABLE TABLE (
[ID] [int] NOT NULL PRIMARY KEY
,[Name] [nvarchar] (255) COLLATE DATABASE_DEFAULT NULL
)

Can I create a index on Name?

+8  A: 

The answer is no. You can only add PRIMARY KEY (as you did) and UNIQUE constraints in the definition of table variable.

Here you can find more information:

http://support.microsoft.com/default.aspx/kb/305977

http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html

Irina C