SQL server Agent job , using steps to add job

Hi,
I am using SQL agent job with steps. I can see many options and have some queries.

How does failure of a step inside job is determined? Do I need to do a return code?
If I am using capture and masking any errors raised how will it handle failure?

Thanks
New-Job-Step-2012-09-12-15-56-53.jpg
crazywolf2010Asked:
Who is Participating?
 
Jared_SConnect With a Mentor Commented:
This is what determines the success or failure of a job step.

If your code cannot execute, then the job step fails.

If your code executes, but doesn't necessarily do what you want it to do, the job succeeds.

In  the case of SSIS packages set up as job steps, the designer sets the number of acceptable errors within a package before the package will fail (thus failing the job step).

In the case of SQL code, if the sql code has an error and does not execute, the job step fails.

If this still doesn't answer your question, can you restate it?
0
 
Jared_SCommented:
If you have error handling built into the code of your step, then your step could theoretically never fail.

The job status could be thought of as
success = able to run the command
and
failure = not able to run the command .

If you want to raise an error based on a specific condition in your query, then you can use this:

IF Put Your Boolean Test Here
 BEGIN
   RAISERROR('50005 Put your message regarding the failure here',16, -1, @@servername )
 END

Open in new window

0
 
crazywolf2010Author Commented:
Hi,
I am asking how does steps within job work? How does a success/failure of a step is measured?

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.