Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved 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: 4372 | Views in the last 30 days: 6
 
Related Articles
FORUM

DBCC REINDEX - Offline?

Can DBCC REINDEX be run while the database is online?

FORUM

SQL 2008 Std. Edition Maintenance Plan Wizard

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

SCRIPT

Reindexing for fragmented indexes

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

FORUM

Reindexing

Reindexing tables with less than 1000 pages

FORUM

indexing online vs offline, and setting a database offline

indexing online vs offline, and setting a database offline

 
Contribute

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
Editor, SQLServerCentral.com

Already a member? Jump in:

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