Well, if you know the job name, you can query the msdb..sysjobs table for
the job_id and join it to the sysjobhistory table for the error message.
I'm not aware of any way to find the job name on demand though. If you know
the job name at the time you create the job, just use it in a select query
in Step 2 to get the other data, then issue your raiserror statement.
Kevin Martin
Database Engineer
Multimedia Games
-----Original Message-----
From: S, Sathish K (EM, GECIS) [mailto:Sathish.[Email Address Removed] Tuesday, July 29, 2003 10:29 AM
To: LazyDBA.com Discussion
Subject: 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] 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] mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.501 / Virus Database: 299 - Release Date: 7/14/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.501 / Virus Database: 299 - Release Date: 7/14/2003
MS Sql Server LazyDBA home page