Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
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)

Reindex all indexes online or offline depending on day of week.

By Kenneth Singer,

This script will attempt to reindex any index online that is possible/eligible to be reindexed online. The script will accept a parameter indicating what day of the week to run normal reindexing on all tables indexes.

The design of this script is with intent to only have one maintenance job/step per db for reindexing. The intent is that this be scheduled to run daily, reindexing online - whatever can be reindexed online, and on the day matching the day of week parameter a full reindex will occur.

Certain types of indexes (e.g. a Clustered index when a table also happens to contain an image datatype column) cannot be reindexed online. This query will filter out such indexes and reindex online only what it can.

A day of week parameter (@dow) exists to allow a full normal reindex operation. Set this to a particular day where you have a maintenance window or period of low activity.

This is quite helpful with Sharepoint in particular, where reindexing the audit table in a content database can create a huge mess of blocked processes - and an incredible amount of MOM alerts.

Total article views: 4518 | Views in the last 30 days: 4
Related Articles

A Spectacular Case of 100% CPU Caused by Online Reindexing

An investigation of a serious performance issue during online re-indexing on a production server lea...


Grant Fritchey Reviews Minion Reindex

Grant Fritchey reviews Midnight DBA's Minion Reindex, a highly customizable set of scripts that take...



Can DBCC REINDEX be run while the database is online?


SQL 2008 Std. Edition Maintenance Plan Wizard

Keep Index Online While Reindexing...question...


Reindexing for fragmented indexes

Script will give you the list of fragemented indexes. (For SQL 2005-2008)


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones