Home All Groups Group Topic Archive Search About

sql server agent job failing on an error I am handling in code

Author
20 Oct 2005 11:35 AM
Kevin S
I have a sqlserver agent job which simply executes a procedure to load data
from intermediate tables to corresponding application tables.

Withing the procedure, I am handling errors so I can log which records are
causing problems, while continuing processing so any subsequent correct
records can still be processed.

When I run the procedure through query analyser the error handling works fine.

When I call it through a sql server agent job, the job fails despite the
error handling.

Any idea whay this is?

Author
20 Oct 2005 11:55 AM
Tibor Karaszi
Agent terminates a job step on any error > 10. Use CmdExec job step instead and use OSQL to execute
your script file.

Show quote
"Kevin S" <Kevin S@discussions.microsoft.com> wrote in message
news:8526BB51-DE5F-472A-A73F-7D4A21132F79@microsoft.com...
>I have a sqlserver agent job which simply executes a procedure to load data
> from intermediate tables to corresponding application tables.
>
> Withing the procedure, I am handling errors so I can log which records are
> causing problems, while continuing processing so any subsequent correct
> records can still be processed.
>
> When I run the procedure through query analyser the error handling works fine.
>
> When I call it through a sql server agent job, the job fails despite the
> error handling.
>
> Any idea whay this is?
Author
20 Oct 2005 12:16 PM
Kevin S
Using CmdExec job steps using osql would mask any error however I only want
to handle errors caused by constraint violations; not system errors which the
dba would want to know about.

Is this possible?

Show quote
"Tibor Karaszi" wrote:

> Agent terminates a job step on any error > 10. Use CmdExec job step instead and use OSQL to execute
> your script file.
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
>
> "Kevin S" <Kevin S@discussions.microsoft.com> wrote in message
> news:8526BB51-DE5F-472A-A73F-7D4A21132F79@microsoft.com...
> >I have a sqlserver agent job which simply executes a procedure to load data
> > from intermediate tables to corresponding application tables.
> >
> > Withing the procedure, I am handling errors so I can log which records are
> > causing problems, while continuing processing so any subsequent correct
> > records can still be processed.
> >
> > When I run the procedure through query analyser the error handling works fine.
> >
> > When I call it through a sql server agent job, the job fails despite the
> > error handling.
> >
> > Any idea whay this is?
>
>
Author
22 Oct 2005 1:07 PM
Tibor Karaszi
This would be no different from a CmdExec job. Even if you handle an error, the error has still been
raised (to either Agent or OSQL).

Show quote
"Kevin S" <Kev***@discussions.microsoft.com> wrote in message
news:EE7494A7-D3E7-4D1D-863C-EBC8073300BF@microsoft.com...
> Using CmdExec job steps using osql would mask any error however I only want
> to handle errors caused by constraint violations; not system errors which the
> dba would want to know about.
>
> Is this possible?
>
> "Tibor Karaszi" wrote:
>
>> Agent terminates a job step on any error > 10. Use CmdExec job step instead and use OSQL to
>> execute
>> your script file.
>>
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>> Blog: http://solidqualitylearning.com/blogs/tibor/
>>
>>
>> "Kevin S" <Kevin S@discussions.microsoft.com> wrote in message
>> news:8526BB51-DE5F-472A-A73F-7D4A21132F79@microsoft.com...
>> >I have a sqlserver agent job which simply executes a procedure to load data
>> > from intermediate tables to corresponding application tables.
>> >
>> > Withing the procedure, I am handling errors so I can log which records are
>> > causing problems, while continuing processing so any subsequent correct
>> > records can still be processed.
>> >
>> > When I run the procedure through query analyser the error handling works fine.
>> >
>> > When I call it through a sql server agent job, the job fails despite the
>> > error handling.
>> >
>> > Any idea whay this is?
>>
>>

AddThis Social Bookmark Button