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.