RE: Getting the JobID and jobname within the steps of the same JO B

RE: Getting the JobID and jobname within the steps of the same JO B

 

  

I want to pick it up dynamically from within the job.

For example,
if I have a job by "db1 purging job"
1. the step 1 will have the actual purging script
2.On failure of Step 1, I will call step 2 of job, which will have the
raiserror. It should get the job id and jobname from where it was called
dynamically(ie., calling job's information).



-----Original Message-----
From: Ken Nickels [mailto:[Email Address Removed] Tuesday, July 29, 2003 8:55 PM
To: S, Sathish K (EM, GECIS)
Subject: RE: Getting the JobID and jobname within the steps of the same
JO B


Take a look at msdb..sysjobs and msdb..sysjobhistory. All the fields you
want are in there.

-----Original Message-----
From: S, Sathish K (EM, GECIS) [mailto:Sathish.[Email Address Removed] Tuesday, July 29, 2003 11:14 AM
To: LazyDBA.com Discussion
Subject: FW: Getting the JobID and jobname within the steps of the same
JO B


> Hi,
>
> I am trying to automate the alerting to multiple DBAs and monitoring
> people. Hence, want to use "raiserror" with a custom message with the
> details of the server, jobid,jobname, and error message
>
> I know that the server name can be got from @@servername
>
> RAISERROR (99999, 17, 1, @@servername,null,null)
>
> How do I get the jobid, jobname and error message for the failure.
>
> Regards,
>
> Sathish

---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To unsubscribe, e-mail: mssqldba-[Email Address Removed] additional commands, e-mail: mssqldba-[Email Address Removed]MS Sql Server LazyDBA home page