Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Index help

Author  Topic 

dowens
Yak Posting Veteran

82 Posts

Posted - 2005-07-08 : 13:30:30
I need to create several simple indexes on one table.
I have to use a stored procedure to normalize the tables from a legacy system.
I want to create the indexes within the SP.

How can I stack the indexes?
I need 3 indexes LOB, Group, and Region.
Do I have to enter the code below for each field I want to index?

CREATE
INDEX [ak_MC_LOB] ON [dbo].[dw_MC] ([LOB])
WITH
PAD_INDEX
,FILLFACTOR = 100
,DROP_EXISTING
ON [PRIMARY]

Any thoughts?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-07-08 : 13:32:16
Do you want 3 indexes or 1 composite index?

Don't create the indexes in a stored procedure. Just create them once inside Query Analyzer. They'll then be there for everyone to use and not just the user executing the stored procedure.

Tara
Go to Top of Page

dowens
Yak Posting Veteran

82 Posts

Posted - 2005-07-08 : 13:35:21
Not a composit index simple.

The stored procedure is used daily to refresh (D/W) (all tables truncated).
If the indexes are created once should they be dropped and recreated each time?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-07-08 : 13:40:47
3 indexes:

CREATE CLUSTERED INDEX idx_SomeTable_SomeColumn1 ON SomeTable (SomeColumn1)
CREATE NONCLUSTERED INDEX idx_SomeTable_SomeColumn2 ON SomeTable (SomeColumn2)
CREATE NONCLUSTERED INDEX idx_SomeTable_SomeColumn3 ON SomeTable (SomeColumn3)


Tara
Go to Top of Page

dowens
Yak Posting Veteran

82 Posts

Posted - 2005-07-08 : 13:47:00
Thanks Tara!!
Go to Top of Page
   

- Advertisement -