Returns information for the steps in a job used by SQL Server Agent service to perform automated activities.
Unique identifier for the step.
Name of the step in the job.
Subsystem in which to execute the step command.
Command executed in the step.
A bitmask of values that control step behavior.
For a CmdExec step, this is the process exit code of a successful command.
Action to take if the step succeeds:
1 = Quit the job reporting success.
2 = Quit the job reporting failure.
3 = Go to the next step.
4 = Go to step.
If on_success_action is 4, this indicates the next step to execute.
What to do if the step fails. Values are same as on_success_action.
If on_fail_action is 4, this indicates the next step to execute.
For a Transact-SQL step, this is the database in which the command executes.
For a Transact-SQL step, this is the database user context in which the command executes.
Maximum number of times the command should be retried (if it is unsuccessful).
Interval (in minutes) for any retry attempts.
File to which command output should be written (Transact-SQL, CmdExec, and PowerShell steps only).
Outcome of the step the last time it ran:
0 = Failed
1 = Succeeded
2 = Retry
3 = Canceled
5 = Unknown
Duration (in seconds) of the step the last time it ran.
Number of times the command was retried the last time the step ran.
Date the step last started execution.
Time the step last started execution.
Proxy for the job step.
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:
For details about the permissions of these roles, see SQL Server Agent Fixed Database Roles.
Members of SQLAgentUserRole can only view job steps for jobs that they own.
A. Return information for all steps in a specific job
The following example returns all the job steps for the job named Weekly Sales Data Backup.
USE msdb ; GO EXEC dbo.sp_help_jobstep @job_name = N'Weekly Sales Data Backup' ; GO
B. Return information about a specific job step
The following example returns information about the first job step for the job named Weekly Sales Data Backup.
USE msdb ; GO EXEC dbo.sp_help_jobstep @job_name = N'Weekly Sales Data Backup', @step_id = 1 ; GO