Use the Maintenance Plan Wizard
This topic describes how to create a single server or multiserver maintenance plan using the Maintenance Plan Wizard in SQL Server 2012. The Maintenance Plan Wizard creates a maintenance plan that Microsoft SQL Server Agent can run on a regular basis. This allows you to perform various database administration tasks, including backups, database integrity checks, or database statistics updates, at specified intervals.
In This Topic
Limitations and Restrictions
-
To create a multiserver maintenance plan, a multiserver environment containing one master server and one or more target servers must be configured. Multiserver maintenance plans must be created and maintained on the master server. These plans can be viewed, but not maintained, on target servers.
-
Members of the db_ssisadmin and dc_admin roles may be able to elevate their privileges to sysadmin. This elevation of privilege can occur because these roles can modify Integration Services packages; these packages can be executed by SQL Server using the sysadmin security context of SQL Server Agent. To guard against this elevation of privilege when running maintenance plans, data collection sets, and other Integration Services packages, configure SQL Server Agent jobs that run packages to use a proxy account with limited privileges or only add sysadmin members to the db_ssisadmin and dc_admin roles.
Security
To start the Maintenance Plan Wizard
-
Expand the server where you want to create your management plan.
-
Expand the Management folder.
-
Right-click the Maintenance Plans folder and select Maintenance Plan Wizard.
-
On the SQL Server Maintenance Plan Wizard page, click Next.
-
On the Select Plan Properties page:
-
In the Name box, enter the name of the maintenance plan you are creating.
-
In the Description box, briefly describe your maintenance plan.
-
In the Run as list, specify the credential that Microsoft SQL Server Agent uses when executing the maintenance plan.
-
Select either Separate schedules for each task or Single schedule for the entire plan or no schedule to specify the recurring schedule of the maintenance plan.
Note
If you select Separate schedules for each task, you will need to follow the steps in e. below for each task in your maintenance plan.
-
If you selected Single schedule for the entire plan or no schedule, under Schedule, click Change.
-
In the New Job Schedule dialog box, in the Name box, enter the job schedule’s name.
-
On the Schedule type list, select the type of schedule:
-
Start automatically when SQL Server Agent starts
-
Start whenever the CPUs become idle
-
Recurring. This is the default selection.
-
One time
-
-
Select or clear the Enabled check box to enable or disable the schedule.
-
If you select Recurring:
-
Under Frequency, on the Occurs list, specify the frequency of occurrence:
-
If you select Daily, in the Recurs every box, enter how often the job schedule repeats in days.
-
If you select Weekly, in the Recurs every box, enter how often the job schedule repeats in weeks. Select the day or days of the week on which the job schedule is run.
-
If you select Monthly, select either Day or The.
-
If you select Day, enter both the date of the month you want the job schedule to run and how often the job schedule repeats in months. For example, if you want the job schedule to run on the 15th day of the month every other month, select Day and enter “15” in the first box and “2” in the second box. Please note that the largest number allowed in the second box is “99”.
-
If you select The, select the specific day of the week within the month that you want the job schedule to run and how often the job schedule repeats in months. For example, if you want the job schedule to run on the last weekday of the month every other month, select Day, select last from the first list and weekday from the second list, and then enter “2” in the last box. You can also select first, second, third, or fourth, as well as specific weekdays (for example: Sunday or Wednesday) from the first two lists. Please note that the largest number allowed in the last box is “99”.
-
-
-
Under Daily frequency, specify how often the job schedule repeats on the day the job schedule runs:
-
If you select Occurs once at, enter the specific time of day when the job schedule should run in the Occurs once at box. Enter the hour, minute, and second of the day, as well as AM or PM.
-
If you select Occurs every, specify how often the job schedule runs during the day chosen under Frequency. For example, if you want the job schedule to repeat every 2 hours during the day that the job schedule is run, select Occurs every, enter “2” in the first box, and then select hour(s) from the list. From this list you can also select minute(s) and second(s). Please note that the largest number allowed in the first box is “100”.
In the Starting at box, enter the time that the job schedule should start running. In the Ending at box, enter the time that the job schedule should stop repeating. Enter the hour, minute, and second of the day, as well as AM or PM.
-
-
Under Duration, in Start date, enter the date that you want the job schedule to start running. Select End date or No end date to indicate when the job schedule should stop running. If you select End date, enter the date that you want to job schedule to stop running.
-
-
If you select One Time, under One-time occurrence, in the Date box, enter the date that the job schedule will be run. In the Time box, enter the time that the job schedule will be run. Enter the hour, minute, and second of the day, as well as AM or PM.
-
Under Summary, in Description, verify that all job schedule settings are correct.
-
Click OK.
-
-
Click Next.
-
-
On the Select Target Servers page, select the servers where you want to run the maintenance plan. This page is only visible on SQL Server instances that are configured as master servers.
Note
To create a multiserver maintenance plan, a multiserver environment containing one master server and one or more target servers must be configured, and the local server should be configured as a master server. In multiserver environments, this page displays the (local) master server and all corresponding target servers.
-
On the Select Maintenance Tasks page, select one or more maintenance tasks to add to the plan. When you have selected all of the necessary tasks, click Next.
Note
The tasks you select here will determine which pages you will need to complete after the Select Maintenance Task Order page below.
-
On the Select Maintenance Task Order page, select a task and click either Move Up… or Move Down… to change its order of execution. When finished, or if you are satisfied with the current order of tasks, click Next.
Note
If you selected Separate schedules for each task on the Select Plan Properties page above, you will not be able to change the order of the maintenance tasks on this page.
Define Database Check Integrity (CHECKDB) Tasks
-
On the Define Database Check Integrity Task page, choose the database or databases where the allocation and structural integrity of user and system tables and indexes will be checked. By running the DBCC CHECKDB Transact-SQL statement, this task ensures that any integrity problems with the database are reported, thereby allowing them to be addressed later by a system administrator or database owner. For more information, see DBCC CHECKDB (Transact-SQL)When complete, click Next.
The following options are available on this page.
Define Database Shrink Tasks
-
On the Define Shrink Database Task page, create a task that attempts to reduce the size of the selected databases by using the DBCC SHRINKDATABASE statement, with either the NOTRUNCATE or TRUNCATEONLY option. For more information, see DBCC SHRINKDATABASE (Transact-SQL). When complete, click Next.
Caution
Data that is moved to shrink a file can be scattered to any available location in the file. This causes index fragmentation and can slow the performance of queries that search a range of the index. To eliminate the fragmentation, consider rebuilding the indexes on the file after shrinking.
The following options are available on this page.
Define the Index Tasks
-
On the Define Reorganize Index Task page, select the server or servers where you'll be moving index pages into a more efficient search order. This task uses the ALTER INDEX … REORGANIZE statement. For more information, see ALTER INDEX (Transact-SQL). When complete, click Next.
The following options are available on this page.
-
On the Define Rebuild Index Task page, select the database or databases where you'll be re-creating multiple indexes. This task uses the ALTER INDEX … REBUILD PARTITION statement. For more information, see ALTER INDEX (Transact-SQL).) When complete, click Next.
The following options are available on this page.
Define the Update Statistics Task
-
On the Define Update Statistics Task page, define the database or databases on which table and index statistics will be updated. This task uses the UPDATE STATISTICS statement. For more information, see UPDATE STATISTICS (Transact-SQL) When finished, click Next
The following options are available on this page.
Define the History Cleanup Task
-
On the Define History Cleanup Task page, define the database or databases where you want to discard old task history. This task uses the EXEC sp_purge_jobhistory, EXEC sp_maintplan_delete_log, and EXEC sp_delete_backuphistory statements to remove history information from the msdb tables. When finished, click Next.
The following options are available on this page.
Define the Execute Agent Job Task
-
On the Define Execute Agent Job Task page, under Available SQL Server Agent jobs, choose the job or jobs to run. This option will not be available if you have no SQL Agent jobs. This task uses the EXEC sp_start_job statement. For more information, see sp_start_job (Transact-SQL)When finished, click Next.
Define Backup Tasks
-
On the Define Backup Database (Full) Task page, select the database or databases on which to run a full backup. This task uses the BACKUP DATABASE statement. For more information, see BACKUP (Transact-SQL). When finished, click Next.
The following options are available on this page.
-
On the Define Backup Database (Differential) Task page, select the database or databases on which to run a partial backup. See the definition list in step 16, above, for more information about the available options on this page. This task uses the BACKUP DATABASE … WITH DIFFERENTIAL statement. For more information, see BACKUP (Transact-SQL). When finished, click Next.
-
On the Define Backup Database (Transaction Log) Task page, select the database or databases on which to run a backup for a transaction log. See the definition list in step 16, above, for more information about the available options on this page. This task uses the BACKUP LOG statement. For more information, see BACKUP (Transact-SQL). When finished, click Next.
Define Maintenance Cleanup Tasks
-
On the Define Maintenance Cleanup Task page, specify the types of files to delete as part of the maintenance plan, including text reports created by maintenance plans and database backup files. This task uses the EXEC xp_delete_file statement. When finished, click Next.
Important
This task does not automatically delete files in the subfolders of the specified directory. This precaution reduces the possibility of a malicious attack that uses the Maintenance Cleanup task to delete files. If you want to delete files in first-level subfolders, you must select Include first-level subfolders.
The following options are available on this page.
Select Report Options
-
On the Select Report Options page, select options for saving or distributing a report of the maintenance plan actions. This task uses the EXEC sp_notify_operator statement. For more information, see sp_notify_operator (Transact-SQL).When finished, click Next.
The following options are available on this page.
Complete the Wizard
-
On the Complete the Wizard page, verify the choices made on the previous pages, and click Finish.
-
On the Maintenance Wizard Progress page, monitor status information about the actions of the Maintenance Plan Wizard. Depending on the options that you selected in the wizard, the progress page might contain one or more actions. The top box displays the overall status of the wizard and the number of status, error, and warning messages that the wizard has received.
The following options are available on the Maintenance Wizard Progress page: