Re: Index's

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 01/31/05


Date: Mon, 31 Jan 2005 21:30:50 +0100

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)


Relevant Pages

  • Re: potential top
    ... Phil. ... >> cheaper to do the entire select into a temp table and then select TOP ... >> WHERE MyCondition ...
    (microsoft.public.sqlserver.programming)
  • 21 today
    ... Phil ... Guildford 03/05/06 4:58Z ... Temp 7.9°C ... Rain 0.0mm ...
    (uk.sci.weather)
  • Re: Model thickness dams
    ... for a -5c temp as a better guide? ... Phil ... Prev by Date: ...
    (uk.sci.weather)
  • Re: After SP2 upgrade
    ... Phil --> It takes around 2 GB of Hard drive, so it is stranger tht yr HDD ... >> install fail to remove some TEMP. ...
    (microsoft.public.windowsxp.general)
  • Re: RUNNING COUNT Function
    ... I assume there is a primary key somewhere in the table? ... It could turn to be much faster with the RANK syntax, ... WITH temp ... When designed, partial-years werent known about. ...
    (microsoft.public.access.queries)