sp_delete_jobstep (Transact-SQL)

 

Updated: August 9, 2016

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

Removes a job step from a job.

Topic link icon Transact-SQL Syntax Conventions

  
sp_delete_jobstep { [ @job_id = ] job_id | [ @job_name = ] 'job_name' } ,   
     [ @step_id = ] step_id   

[ @job_id= ] job_id
The identification number of the job from which the step will be removed. job_idis uniqueidentifier, with a default of NULL.

[ @job_name= ] 'job_name'
The name of the job from which the step will be removed. job_nameis sysname, with a default of NULL.

NOTE: Either job_id or job_name must be specified; both cannot be specified.

[ @step_id= ] step_id
The identification number of the step being removed. step_idis int, with no default.

0 (success) or 1 (failure)

None

Removing a job step automatically updates the other job steps that reference the deleted step.

For more information about the steps associated with a particular job, run sp_help_jobstep.

NOTE: Calling sp_delete_jobstep with a step_id value of zero deletes all job steps for the job.

Microsoft SQL Server Management Studio provides an easy, graphical way to manage jobs, and is the recommended way to create and manage the job infrastructure.

By default, members of the sysadmin fixed server role can execute this stored procedure. 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.

Only members of sysadmin can delete a job step that is owned by another user.

The following example removes job step 1 from the job Weekly Sales Data Backup.

USE msdb ;  
GO  
  
EXEC dbo.sp_delete_jobstep  
    @job_name = N'Weekly Sales Data Backup',  
    @step_id = 1 ;  
GO  

View or Modify Jobs
sp_add_jobstep (Transact-SQL)
sp_update_jobstep (Transact-SQL)
sp_help_jobstep (Transact-SQL)
System Stored Procedures (Transact-SQL)

Community Additions

ADD
Show: