SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

SQL Server 2005 Index Maintenance

By Luke C, 2008/05/29

Total article views: 94 | Views in the last 30 days: 57

The first procedure is based on the process found in Books Online. However the cursor has been replaced with a while loop and modified to accept a database name as a parameter. Using dynamic sql I was able to overcome the issue in having to deploy to each db on the server. The procedure will REORGANIZE any indexes that have a fragementation level between 20 & 30 percent and has a page count greater than 10. The REBUILD parameter will be used if the fragmentation level is 30 percent or above. I have also added the ability to log information into a table regarding start & end times (currently set to Insert into DBInfo in a database named MAINT). Uses the SORT_IN_TEMPDB and ONLINE options (Please see BOL for more information on these options before deploying to your environment).

The second procedure will cycle through each non system database on the server and execute the uspIndexMaintenance script.

By Luke C, 2008/05/29

Total article views: 94 | Views in the last 30 days: 57
Your response
 
 
Related tags

index     Maintenance    
Indexes     SQL Server 2005    
 
Related content

What does SMO mean in SQL Server 2005?

(not yet rated) | 1,877 reads

What is database mirroring?

By Steve Jones | Category: SQL Server 2005
(not yet rated) | 2,182 reads

What is the role of a witness in...

By Steve Jones | Category: SQL Server 2005
(not yet rated) | 1,347 reads
Like this? Try these...

SQL 2005 IndexDefrag solution

By Kobus | Category: Indexing
(not yet rated) | 29 reads
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com