SQL Server Agent Jobs: How to execute a job step without executing the entire job

Viewed 50774

I have a SQL Server Agent Job that previously had two steps. Today, I've had to integrate the third step, and soon I'll need to integrate a fourth.

I want to be sure that the step will execute properly but I do not want to execute the entire job.

The first two steps take quite a bit of time to execute and during the day they hog a significant amount of the SQL resources that my users need.

Is there a way that I can execute a job step and not an entire job process?

Within SSMS, if I right-click on the job there is an option that states "Start Job at step..." except when I try that option it brings up a dialog that seems to imply that the entire job has been started. What can I do to test one step within a job?

Thanks in advance.

5 Answers

In SSMS:

  • Copy the code from the job step (use ctrl + a to select all)
  • Paste the code in to a new query window in SSMS
  • Run the code

Alternately if you have a recurring need to run just a couple steps.

Put those steps in a separate job, then kick off one job from the other to run everything. Use EXEC msdb.dbo.sp_start_job N'job_name'

You can run the short easy job on demand, and the full long job as scheduled

USE [**DB_NAME**]
GO

DECLARE @return_value int

EXEC @return_value = [dbo].[**STEP_NAME**]  

SELECT 'Return Value' = @return_value
GO
Related