March 1, 2012 at 6:28 pm
Hi All,
How can we get the job_history_id for the Job Submitted through the SP_STARTJOB Procedure.
When we are triggering the job, we are unable to Understand or get the Details.
the below query works
Select * from msdb.dbo.sysjobhistory where instance_id = (
Select job_history_id from msdb.dbo.sysjobactivity where job_id =
(Select job_id from msdb.dbo.sysjobs where name = 'Test'))
1. But there are chances that the "sysjobactivity" table can have multiple instance of the Same Job.
2. how do we confirm if the result fetched is exactly the outcome of the Present job.
Any details on this will be really Great, if there is any other proc which can retrieve the JOB_HISTORY_ID on submission that will be really useful.
Thanks
Sudhir. 🙂
March 2, 2012 at 1:36 am
you would have to build into the query a where statement for run_requested_date in the activity table which brings back the top row when ordered desc to ensure its the last row that was inserted for that particular job it
March 5, 2012 at 12:27 am
Thanks Anthony,
But it can retrieve the Data which is from Previous Run Too....
So I am looking for some way where I can confirm that the Exact Job ID is retrieved which is Triggered in this Run.
Any suggestion are really helpful
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply