I have a job that has 4 steps, all of which have to run. They are all T-SQL
scripts. How can I get the job to report failure if step 2 fails but step 4
doesn't?Stephanie wrote:
> I have a job that has 4 steps, all of which have to run. They are
> all T-SQL scripts. How can I get the job to report failure if step 2
> fails but step 4 doesn't?
Are you saying you want the job to continue should one of the steps fail
or are you saying you want all the steps to run regardless of success
and have the job report failure if any of the steps fail. If the latter,
then how will you resolve running the failed step?
David Gugick
Quest Software
www.imceda.com
www.quest.com|||I want all steps to run regardless of the status of a particular step but I
want failure of the job as a whole to be based on failure of any one of the
steps. If a step fails, I will worry about that later. But I'd like all
steps to run no matter what and I'd like to get an alert if any of the steps
fail as opposed to just the last step.
"David Gugick" wrote:
> Stephanie wrote:
> Are you saying you want the job to continue should one of the steps fail
> or are you saying you want all the steps to run regardless of success
> and have the job report failure if any of the steps fail. If the latter,
> then how will you resolve running the failed step?
> --
> David Gugick
> Quest Software
> www.imceda.com
> www.quest.com
>|||Stephanie wrote:
> I want all steps to run regardless of the status of a particular step
> but I want failure of the job as a whole to be based on failure of
> any one of the steps. If a step fails, I will worry about that
> later. But I'd like all steps to run no matter what and I'd like to
> get an alert if any of the steps fail as opposed to just the last
> step.
You can check the "Append output to step history" for each step. In the
morning, examine the job history and show step detail. If there were any
failed steps, you'll see them there. Make sure each step is created to
proceed to the next step on failure or success.
select
j.name,
h.*
From
msdb..sysjobs j inner join
msdb..sysjobhistory h
On
j.job_id = h.job_id
and
j.name = N'<job_name>'
and
h.sql_message_id > 0
Order By
j.name,
h.run_date,
h.run_time
-- OR
Exec msdb..sp_help_jobhistory @.job_name = N'<job_name>', @.run_status = 0
David Gugick
Quest Software
www.imceda.com
www.quest.comsql
No comments:
Post a Comment