sp_delete_job

Transact-SQL Reference

Transact-SQL Reference

sp_delete_job

Deletes a job.

Syntax

sp_delete_job [ @job_id = ] job_id | [ @job_name = ] 'job_name'
    [ , [ @originating_server = ] 'server' ]

Arguments

[@job_id =] job_id

Is the identification number of the job to be deleted. job_id is uniqueidentifier, with a default of NULL.

[@job_name =] 'job_name'

Is the name of the job to be deleted. job_name is sysname, with a default of NULL.

Note  Either job_id or job_name must be specified; both cannot be specified.

Return Code Values

0 (success) or 1 (failure)

Result Sets

None

Remarks

Two parameters, @delete_history and @originating_server, exist in sp_delete_job, but are reserved for internal use.

SQL Server Enterprise Manager provides an easy, graphical way to manage jobs, and is the recommended way to create and manage the job infrastructure.

Permissions

Anyone can delete jobs he owns. Only members of the sysadmin fixed server role can execute sp_delete_job to delete any job.

Examples

This example deletes the job Nightly Backups.

USE msdb
EXEC sp_delete_job @job_name = 'Nightly Backups'

See Also

sp_add_job

sp_help_job

sp_update_job

System Stored Procedures