SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Disable or rebuild all nonclustered indexes on a table

By Jonathan Roberts,

I use this when inserting data into a staging table on  a data warehouse. 

If inserting data into an empty table it is faster to insert data when the indexes are disabled and then rebuild the indexes once the insert has completed than to insert all the data with the indexes enabled.

If you disable a clustered index then you won't be able to insert any data onto the table. So this script only disables and then rebuilds nonclustered indexes.

Total article views: 230 | Views in the last 30 days: 226
Related Articles

Disabling Indexes

Expert SQL Server trainer Andy Warren brings us a new article on a lesser used feature in SQL server...


Enable/Disable all indexes in all tables at once

Enable/Disable Indexes



Use the script below to disable an index on a SQL Server table ALTER INDEX MY_INDEX_NAME on MY_TABL...


Copying Data From One Table To Another – To Disable Indexes or Not To Disable Indexes, That’s the Question.

As the famous Bard once said, “To disable indexes or not to disable indexes, that is the question?...


Disabling index by using select query

Disabling index by using select query

disable indexes    
rebuild indexes