Disable/Enable Index

  • What is the tsql cmd to disable and enable all indexes of a table at once.

    I am tryingto do something like this in a job.

    1.Disable INDEX (ALTER INDEX ALL ON table DISABLE)

    2.ALTER TABLE Alter column collation

    3.Enable INDEX (ALTER INDEX ALL ON table ENABLE)

    Cud some one let me know whats the difference or Pros/Cons between

    Drop/Create Index and Disable/Enable.

    Thanks

  • You would use ALTER INDEX ALL to disable and rebuild indexes. See "ALTER INDEX" in BOL.

    ALTER INDEX ALL ON table DISABLE

    ALTER INDEX ALL ON table REBUILD

    I don't think there's a practical difference since you reenable an index by using ALTER INDEX REBUILD and rebuilding the index drops and recreates the index.

    Greg

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply