sp_sjobdrop

Description

Deletes a job, a schedule, or a scheduled job.

By default, the name argument is the name or ID of a scheduled job. To specify the name or ID for a job or a schedule the name argument is prefixed with jname or sname.

Syntax

sp_sjobdrop @name=’...’, @option=’...’

Parameters

name

The name or ID of the scheduled job, job, or schedule to delete.

option

A list of options for the command:

  • all – used with a job or schedule to specify that all scheduled jobs owned by the caller that are using the specified job or schedule should also be deleted. When used with a scheduled job, it specifies that the job and schedule associated with the scheduled job should also be deleted, provided that no other scheduled jobs reference them.

  • all_users – allows a user with the js_admin_role to use sp_sjobdrop on scheduled jobs, jobs, and schedules that are owned by someone else.

  • show – displays the jobs, schedules, and scheduled jobs that will be deleted by this call to sp_sjobdrop, before any deleting occurs.

  • force – allows you to remove jobs from the database, even if they are currently running.

(See the Usage section for more details on these parameters.)

Returns

Returns 0 on success or an error code.

Examples

Example 1

The following example deletes the scheduled job called “svr1_clean_stats”:

sp_sjobdrop ’svr1_clean_stats’

Example 2

The following example deletes the schedule called “daily 01:00am”:

sp_sjobdrop ’sname=daily 01:00am’

Example 3

The following example deletes the job called “load_sales_data”:

sp_sjobdrop ’jname=load_sales_data’

Example 4

The following example deletes the job called “load_sales_data” and any scheduled jobs the caller owns that were using it.

sp_sjobdrop @name=’jname=load_sales_data’, @option=’all’

Usage

For the general administration of jobs and schedules, the all and all_users options are provided. The following describes these options:

The show option is provided so you can see which scheduled jobs, jobs, and schedules would be deleted by a call to sp_dropjob—without actually deleting them.