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

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.