Вы находитесь на странице: 1из 25

Ramco Enterprise Series

Scheduling Database Maintenance Plans using

Maintenance Plan Wizard in SQL Server 2008


©2010 Ramco Systems Ltd. All rights reserved. All trademarks acknowledged.

This document is published by Ramco Systems Ltd. without any warranty.

No part of this document may be reproduced or transmitted in any form or by any means,
electronic or mechanical, for any purpose without the written permission of Ramco Systems
Limited.

Improvements and changes to this text necessitated by typographical errors, inaccuracies of


current information or improvements to software programs and/or equipment, may be made
by Ramco Systems Limited, at any time and without notice. Such changes will, however, be
incorporated into new editions of this document. Any hard copies of this document are to be
regarded as temporary reference copies only.

Digitally Signed by Documentation


2010.06.12 12:15:01 +05'30'
Table of Contents

1 Scheduling Database Maintenance Plans using Maintenance Plan Wizard in SQL


Server 2008 ......................................................................................................................... 1
1.1 Starting the Database Maintenance Plan Wizard................................................ 2
1.2 Name the Database Maintenance Plan................................................................ 4
1.3 Select the Tasks for your Maintenance Plan....................................................... 5
1.4 Ordering the Tasks in the Database Maintenance Plan ...................................... 6
1.5 Configure the Plan's Task Details....................................................................... 7
1.6 Define Rebuild Index Task ............................................................................... 11
1.7 Define Update Statistics Task........................................................................... 13
1.8 Backup Database............................................................................................... 14
1.9 Define Maintenance Cleanup Task................................................................... 16
1.10 Choose Maintenance Plan Reporting Options .................................................. 17
1.11 Complete the Wizard ........................................................................................ 18
1.12 Maintenance Plan Wizard Progress .................................................................. 19

i
1 Scheduling Database Maintenance Plans using Maintenance
Plan Wizard in SQL Server 2008
The Maintenance Plan Wizard helps you set up the core maintenance tasks to make
sure that your database performs at top efficiency, is regularly backed up, and is free
of inconsistencies. The Maintenance Plan Wizard creates one or more SQL Server
Agent jobs that perform these tasks.

In this document we discuss about using the Wizard to create plans to perform
following tasks:

¾ Reorganize data on data and index pages by rebuilding indexes with a new fill
factor. Rebuilding indexes with a new fill factor makes sure that database
pages contain an equally distributed amount of data and free space. It also
enables faster growth in the future.

¾ Update index statistics to make sure the query optimizer has current
information about the distribution of data values in the tables. This enables
the query optimizer to make better judgments about the best way to access
data, because it has more information about the data stored in the database.
Although index statistics are automatically updated by SQL Server
periodically, this option can force the statistics to update immediately.

¾ Perform internal consistency checks of the data and data pages within the
database to make sure that a system or software problem has not damaged
data.

¾ Back up the database files. Database backups can be retained for a specified
period. This lets you maintain backup sets to be used if you have to restore
the database to a time earlier than the last database backup. You can also
perform differential backups.

¾ Clean up old backup files.

Note: To create or manage maintenance plans, you must be a member of the sysadmin fixed
server role. Object Explorer only displays the Maintenance Plans node for users who are
members of the sysadmin fixed server role.

ESCS/TEC/SQL2008/Maintenance/100507 1
1.1 Starting the Database Maintenance Plan Wizard

Open Microsoft SQL Server Management Studio (SSMS) and expand the Management
folder. Right-click on the Maintenance Plans folder and select Maintenance Plan
Wizard from the pop-up menu.

ESCS/TEC/SQL2008/Maintenance/100507 2
You will see the wizard's opening screen, as shown below. Click Next to continue.

ESCS/TEC/SQL2008/Maintenance/100507 3
1.2 Name the Database Maintenance Plan

In the next screen that appears, provide a name and description for your database
maintenance plan. Provide relevant information here that will be helpful to another
administrator or yourself after months or years from now.

Select "Separate schedules for each task" to create different plans for different
schedules. You may want to try to use the default option "Single schedule for the
entire plan or no schedule".

Click the Next button when you are finished.

ESCS/TEC/SQL2008/Maintenance/100507 4
1.3 Select the Tasks for your Maintenance Plan

You'll see the window shown below. Include following tasks in your database
maintenance plan.

¾ Backing up a database
¾ Updating database statistics
¾ Verifying the integrity of a database
¾ Cleaning up leftover maintenance files
¾ Rebuilding an index

When you're finished, click the Next button to continue.

ESCS/TEC/SQL2008/Maintenance/100507 5
1.4 Ordering the Tasks in the Database Maintenance Plan

Click the Next button to continue.

ESCS/TEC/SQL2008/Maintenance/100507 6
1.5 Configure the Plan's Task Details

In the Define Database Check Integrity Task select databases against which you
want the task to be executed. This can be done by selecting the drop down list for
databases and then selecting each of the databases against which you want this task
to execute.

ESCS/TEC/SQL2008/Maintenance/100507 7
Click OK to save the list of database against which you want to run the tasks and
also select Include Indexes check box.

ESCS/TEC/SQL2008/Maintenance/100507 8
Click on Change to open up Job Schedule Properties screen as shown in the
below snippet.

Choose schedule type as Recurring and Frequency as Weekly or Daily depending


on the window available for maintenance activities. Click OK to save the schedule
information.

ESCS/TEC/SQL2008/Maintenance/100507 9
Click Next to continue with the wizard.

ESCS/TEC/SQL2008/Maintenance/100507 10
1.6 Define Rebuild Index Task

In the Define Rebuild Index Task select Databases against which you want to
execute this task and leave other values to default.

Choose schedule type as Recurring and Frequency as Daily or Weekly depending


on the window available for maintenance activities. Click OK to save the schedule
information.

ESCS/TEC/SQL2008/Maintenance/100507 11
Click Next to continue with the wizard.

ESCS/TEC/SQL2008/Maintenance/100507 12
1.7 Define Update Statistics Task

In the Define Update Statistics Task screen select databases against which you
want to execute this task and leave other values to default.

Choose schedule type as Recurring and Frequency as Daily or Weekly depending


on the window available for maintenance activities. Click OK to save the schedule
information.

Click Next to continue with the wizard.

ESCS/TEC/SQL2008/Maintenance/100507 13
1.8 Backup Database

In the Backup Database (Full) screen select databases against which you want to
execute this task and check Verify Backup Integrity option. Select Create a
backup file for every database and provide a valid path to which the databases
need to be backed up.

Choose schedule type as Recurring and Frequency as Daily. Click OK to save the
schedule information.

ESCS/TEC/SQL2008/Maintenance/100507 14
Click Next to continue with the wizard.

ESCS/TEC/SQL2008/Maintenance/100507 15
1.9 Define Maintenance Cleanup Task

In the Define Maintenance Cleanup Task screen select Backup files and Search
folder and delete files based on an extension options. Provide the file extension
as bak. Choose the file retention period as two days. Note that the file retention
period may vary as per your backup and restore policy.

Choose schedule type as Recurring and Frequency as Daily. Click OK to save the
schedule information.
Click Next to continue with the wizard.

ESCS/TEC/SQL2008/Maintenance/100507 16
1.10 Choose Maintenance Plan Reporting Options

Choose to have the detailed report about the maintenance plan execution saved to a
text file on the server or sent to a user via e-mail.

ESCS/TEC/SQL2008/Maintenance/100507 17
1.11 Complete the Wizard

In the Complete the Wizard screen summary of all the selected options appears.

Click Finish to complete the wizard.

ESCS/TEC/SQL2008/Maintenance/100507 18
1.12 Maintenance Plan Wizard Progress

In the Maintenance Plan Wizard Progress screen you need to make sure that all
the tasks have completed successfully and then click Close to complete the wizard.

ESCS/TEC/SQL2008/Maintenance/100507 19
It is very important for a database administrator to always keep the databases
healthy. Improper database maintenance affects the query performance thereby
resulting in slowing down applications that are using the databases.

It should be a regular practice to ensure that these jobs are finished successfully
everyday and action is to be taken immediately if any discrepancy is observed in the
logs.

To check the status of execution of these maintenance jobs expand Jobs under SQL
Server Agent in SSMS and right click the respective job and click on View History.

ESCS/TEC/SQL2008/Maintenance/100507 20
The history log of the respective job appears like below.

ESCS/TEC/SQL2008/Maintenance/100507 21
Corporate Office and R&D Center
Ramco Systems Limited, 64, Sardar Patel Road, Taramani Chennai – 600 113, India
Tel: +91 (44) 2235 4510. Fax +91 (44) 2235 2884
www.ramco.com