Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 job status

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-04 : 07:21:07
In sql, how do I get the status of a job to see if it has failed or not?
I think there is a table somewhere which holds this information?
Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-04 : 07:31:44
Query on msdb..sysjobhistory table


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-04 : 07:42:34
I found this query as you see below...
How do i check just the status of the job ?
There should be just one line.

The reason I am doing this is to find out if the ssis package has finished succesfully or not. The ssis package is run by a job.


Select
*
From
msdb..sysjobhistory as sysjobhistory
Join msdb..sysjobs as sysjobs on sysjobhistory.job_id=sysjobhistory.job_id
Where
Name='jobname'
and
step_name = 'jobname'
Order
By
Run_Date
Desc,
run_time
Desc
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-04 : 07:46:31
May be I should look for the max run_date?
If so how do i max that because it is in string format.
I tried convert(smalldatetime, run_date) but fails.
Thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-04 : 07:54:26
Make use of dateadd(second,run_time,cast(run_date as char(8)))

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2010-02-04 : 12:40:44
thanks again
Go to Top of Page
   

- Advertisement -