Friday, February 24, 2012

How do I drop indexes?

Hi
How do I drop all the indexes in a database in one go?
Thanks in advance
HWrite a cursor that loops over sysindexes and for each index executes the DR
OP INDEX command. Make
sure that you exclude indid 0 and 255. Also, for indexes created with a PRIM
ARY KEY and UNIQUE
constraint, you need to execute ALTER TABLE ... DROP CONSTRAINT instead of D
ROP INDEX.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"h" <anonymous@.discussions.microsoft.com> wrote in message
news:1d5cc01c45434$42f34bd0$a301280a@.phx
.gbl...
> Hi
> How do I drop all the indexes in a database in one go?
> Thanks in advance
> H|||Hi,
I have wrote a script to do this, please login to MSDN and have a look. This
script will generate
This stored procedure will be useful to generate scripts for below
index categories for DROP as well as CREATE . Probably u can use the DROP
part.
a. Clustered Index associated with a Primary key constraint
b. Non Clustered Index associated with a primary key constraint
c. Non Clustered Index associated with a Unique Key constraint
d. Normal Clustered Index
e. Normal unique Clustered Index
f. Normal Non Clustered Index
g. Normal unique Non Clustered Index
http://www.microsoft.com/india/msdn/articles/196.aspx?
Thanks
Hari
MCDBA
"h" <anonymous@.discussions.microsoft.com> wrote in message
news:1d5cc01c45434$42f34bd0$a301280a@.phx
.gbl...
> Hi
> How do I drop all the indexes in a database in one go?
> Thanks in advance
> H

No comments:

Post a Comment