Script to Enable and Dsable Indexes on a table

Is there a script that I can use to activate and deactivate Indexes on a table
more ▼

asked Jan 18, 2012 at 03:49 AM in Default

HRugbeer gravatar image

91 16 23 23

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first
alter index [indexname] on [tablename] disable
more ▼

answered Jan 18, 2012 at 04:13 AM

Wilfred van Dijk gravatar image

Wilfred van Dijk
1.3k 19 23 30


This mabe a silly question but how would I enable it again.

I assume you change the disable to enable like below but then I get a sytax error

alter index [indexname] on [tablename] enable
Jan 18, 2012 at 04:21 AM HRugbeer

You need to Rebuild the index, to enable it again. Please see [BOL][1] for more help.

[1]: http://msdn.microsoft.com/en-us/library/ms190645.aspx
Jan 18, 2012 at 05:06 AM Usman Butt
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Jan 18, 2012 at 03:49 AM

Seen: 1067 times

Last Updated: Jan 19, 2012 at 02:45 AM