Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
SStteepp bbyy SStteepp
HHooww ttoo -- SSQQLL SSeerrvveerr MMaaiinntteennaannccee PPllaann
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
2
If you are a database administrator this is a must for you to know maintenance plan in
SQL Server. DBA can plan all maintenance tasks in SQL Server under the maintenance
plan. Maintenance plan is a workflow in which you can add variety of maintenance tasks.
With maintenance plan you can perform routine database administration tasks such as
Check database integrity
Perform Index maintenance
Update database statistics
Perform database backups
Maintenance plan creates an Integration Services package under the hood, and it
automatically creates a sub plan SQL Server Job which can be scheduled during the
creation of maintenance plan. And this sql server job will execute the SSIS package which
is created by the maintenance plan. You can add as many sub plan within one
maintenance workflow. Sub plan are nothing but scheduling of the sub plan job runs
under the SQL Server Agent Services.
You can run maintenance plan manually or automatically in defined scheduled in sql jobs.
Each task in one maintenance plan can be scheduled to run separately or in a single
schedule. To execute maintenance plan manually you can right click maintenance plan
which you want to execute and the select “Execute” option, it will perform all the tasks
defined under that maintenance plan.
Point to remember that your database compatibility level should be 80 or higher
otherwise the maintenance plan designer in SQL Server Management Studio doesn’t
display for lower than 80 database compatibility level
You are a DBA so you must be a member of sysadmin role on the database, aren’t you?
To create and manage maintenance plans you need to be a member of sysadmin role,
otherwise you won’t be able see them in object explorer.
SQL Server Maintenance plan Wizard:
Maintenance Plan Wizard provides you easy steps to create maintenance plan and
schedule it easily. You can use Maintenance plan wizard to create a maintenance plan
and add tasks with in the plan and define schedule for the tasks.
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
3
1) Go to the explorer and right click Maintenance Plan; you will see option Maintenance Plan Wizard. See screen shots below
2) In this section you can name the maintenance plan and select weather you want single schedule for the entire plan or separate schedules for each tasks in the plan.
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
4
3) In this step you can select what maintenance tasks you want to perform in the maintenance plan
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
5
4) All the tasks will be listed in this step; you can move up and down to maintain the sequence of the tasks.
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
6
5) You need to specify database for each task you want to perform, you can select one or more database
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
7
6) You can report maintenance plan logs at some folder location or you can get it in email
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
8
7) This is the final step you can review your plan what you are creating if everything is OK and click on Finish button
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
9
Your maintenance plan is ready, below screen shows how the maintenance plan looks
like
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
10
In the above screen shot you can see there is a subplan_1 automatically created after the
maintenance plan created, you can edit the Subplan_1 wherein you can schedule your
maintenance tasks to run. Currently you can in schedule section it displays “Not
Scheduled(On Demand)”
You can also see in below screen shot a SQL Job with the
maintenancePlanName.SubplanName created.
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
11
So there are two ways you edit the schedule for the maintenance plan 1) Directly from
the Job or 2) from the Maintenance plan Subplan edit option
Below screen shot shows the screen shot for defining schedule for the maintenance task
from subplan_1 edit option
Mohammad Nizamuddin Authoring on - www.insqlserver.com | spshare.blogspot.com | shaikhnizam.blogspot.com
12
NOTE: If you are editing maintenance plan schedule directly from SQL Server agent job,
and if you are adding more steps in the same job, all the changes will be last whenever
you will update the maintenance plan from the maintenance plan window. Basically
whenever you edit and save the maintenance plan it also updates the sub plan where
schedule is defined, so you must be careful.