Wednesday, March 21, 2012

Index's

Hi All
Another quick question, is it possible to put a index on a temp table and if
so what is the syntax.
Thanks Phil
On Mon, 31 Jan 2005 09:13:05 -0800, Phil wrote:

>Hi All
>Another quick question, is it possible to put a index on a temp table and if
>so what is the syntax.
>Thanks Phil
Hi Phil,
Did you try it? Did you check BOL?
CREATE TABLE #temp (PK int NOT NULL,
Col1 char(4) NOT NULL,
Col2 varchar(20) DEFAULT NULL,
PRIMARY KEY (PK), -- creates an index
UNIQUE (Col1) -- creates another index
)
go
-- And here's a third way to create an index
CREATE INDEX tmpind ON #temp (Col2)
go
-- Check if it worked
sp_helpindex #temp
-- Clean up the mess
DROP INDEX #temp.tmpind
go
DROP TABLE #temp
go
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)

No comments:

Post a Comment