SQL Jobs - accessing job name

  • Hi All,

    I am wondering if it is possible to programmatically access the name of a SQL Job from one of the steps of that job, using TSQL?

    eg, something like : SELECT [@JOBNAME] ?

    Many Thanks

  • You can't get the job name directly but you can get the job id which you can then use to lookup the name of the job (in msdb.dbo.sysjobs)

    Have a look in MSDN for Using the article called "Tokens in Job Steps". It happens to include an example on how to access sysjobs.

  • Thankyou - that's what I was looking for.

    Cheers

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

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