Delete Jobs

A job is a specified series of operations performed sequentially by SQL Server Agent. By default, jobs are not deleted when execution finishes. You can delete one or more Microsoft SQL Server Agent jobs regardless of success or failure of the job. You can also configure Microsoft SQL Server Agent to automatically delete jobs when they succeed, fail, or complete.

By default, members of the sysadmin fixed server role can execute the sp_delete_job (Transact-SQL) system stored procedure to delete a job. Other users must be granted one of the following SQL Server Agent fixed database roles in the msdb database:

  • SQLAgentUserRole

  • SQLAgentReaderRole

  • SQLAgentOperatorRole

For details about the permissions of these roles, see SQL Server Agent Fixed Database Roles.

Members of the sysadmin fixed server role can execute sp_delete_job to delete any job. A user that is not a member of the sysadmin fixed server role can only delete jobs owned by that user.

Description

Topic

Describes how to delete one or more Microsoft SQL Server Agent jobs.

Delete One or More Jobs

Describes how to configure Microsoft SQL Server Agent to automatically delete jobs when they succeed, fail, or complete.

Automatically Delete a Job