Does anyone know of a way to get the name of the job that is running. Is
there a variable that this is stored in similar to @.@.servername or a stored
procedure that can return this information. I am wanting to capture the
jobname while the job is running
Thanks,
Randy BuntonOne method is to specify a '[JOBID]' token in your job step T-SQL script.
You can then use this value to retrieve the job name from sysjobs. For
example.
SELECT name
FROM msdb..sysjobs
WHERE job_id = CAST([JOBID] AS uniqueidentifier)
Note that SQL Server Agent job tokens can only be specified in the directly
executed script. If you need the value in stored procedures, etc, you can
pass the value as a parameter.
Hope this helps.
Dan Guzman
SQL Server MVP
"Randy Bunton" <buntonrl@.charlestoncpw.com> wrote in message
news:uVYnPsiSEHA.3988@.tk2msftngp13.phx.gbl...
> Does anyone know of a way to get the name of the job that is running. Is
> there a variable that this is stored in similar to @.@.servername or a
stored
> procedure that can return this information. I am wanting to capture the
> jobname while the job is running
> Thanks,
> Randy Bunton
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment