Jobstep and Job Info

  • I'm trying to write a bit of TSQL into a job that will return the job step name (or ID) so I can pipe it into a second step that will email if a particular job step failed.  All the job step names and IDs are stored in msdb.dbo.sysjobsteps, so that's not too hard to get to.  What I'm looking for is a system variable or function that will allow me to take the name of the currently running job and throw it into a user-defined variable.  There has to be something the SQL Agent is doing that is similar to this.

  • When a job is running, it will get put into sysjobhistory with a status. BOL lists the various status values.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply