sp_help_maintenance_plan (Transact-SQL)


Updated: August 9, 2016

THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Returns information about the specified maintenance plan. If a plan is not specified, this stored procedure returns information about all maintenance plans.

NOTE: This stored procedure is used with database maintenance plans. This feature has been replaced with maintenance plans which do not use this stored procedure. Use this procedure to maintain database maintenance plans on installations that were upgraded from a previous version of SQL Server.

This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

Topic link icon Transact-SQL Syntax Conventions

sp_help_maintenance_plan [ [ @plan_id = ] 'plan_id' ]  

[ @plan_id =] 'plan_id'
Specifies the plan ID of the maintenance plan. plan_id is UNIQUEIDENTIFIER. The default is NULL.


If plan_id is specified, sp_help_maintenance_plan will return three tables: Plan, Database, and Job.

Plan Table

Column nameData typeDescription
plan_iduniqueidentifierMaintenance plan ID.
plan_namesysnameMaintenance plan name.
date_createddatetimeDate the maintenance plan was created.
ownersysnameOwner of the maintenance plan.
max_history_rowsintMaximum number of rows allocated for recording the history of the maintenance plan in the system table.
remote_history_serverintThe name of the remote server to which the history report could be written.
max_remote_history_rowsintMaximum number of rows allocated in the system table on a remote server to which the history report could be written.
user_defined_1intDefault is NULL.
user_defined_2nvarchar(100)Default is NULL.
user_defined_3datetimeDefault is NULL.
user_defined_4uniqueidentifierDefault is NULL.

Database Table

Column nameDescription
database_nameName of all databases associated with the maintenance plan. database_name is sysname.

Job Table

Column nameDescription
job_idID of all jobs associated with the maintenance plan. job_id is uniqueidentifier.

sp_help_maintenance_plan is in the msdb database.

Only members of the sysadmin fixed server role can execute sp_help_maintenance_plan.

This example descriptive information about the maintenance plan FAD6F2AB-3571-11D3-9D4A-00C04FB925FC.

EXECUTE   sp_help_maintenance_plan   

Maintenance Plans
Database Maintenance Plan Stored Procedures (Transact-SQL)

Community Additions