Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #769
| From | JAW <jwilliam@aglresources.com> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | Re: SQL Agent job RAISEERROR roll-up |
| Date | 2011-11-01 09:39 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <8d4ae597-e41f-4344-96b0-a0cc75c4964e@v5g2000vbh.googlegroups.com> (permalink) |
| References | <e5f0f35a-1624-40ff-aff9-877c1156d5bd@a12g2000vbz.googlegroups.com> <Xns9F8FE71831DYazorman@127.0.0.1> <3534eba6-eb7c-487e-b06a-a37cdb91b6f7@g7g2000vbv.googlegroups.com> |
On Nov 1, 10:02 am, JAW <jwill...@aglresources.com> wrote: > On Oct 31, 5:43 pm, Erland Sommarskog <esq...@sommarskog.se> wrote: > > > > > > > JAW (jwill...@aglresources.com) writes: > > > I have and SPROC that calls the below via a cursor so parameters can > > > be based from a table. > > > > When in run it in SSMS it gives the desired results. Any file that > > > errors it it continues on to the next which is what I want. > > > > When I take the caller of the below and put it in a SQL Agent job it > > > dies on the first error. > > > > Somehow the RAISEERROR percolates to the top of the stack and stops > > > the job. > > > This seems familiar; When Agent notices that the job raises and error, it > > sends an attention signal to SQL Server to cancel execution. I don't know > > of any way to change this behaviour. I think your best bet is to log the > > errors in a table, and then raise an error at the end. > > > -- > > Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se > > > Links for SQL Server Books Online: > > SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx > > SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx > > Changing the RAISERROR to PRINT gives the desired result though I > don't consider it clean programming. > > I have going to try changing the serverity level next. > > A TRY block must be immediately followed by a CATCH block. > > TRY…CATCH constructs can be nested. This means that TRY…CATCH > constructs can be placed inside other TRY and CATCH blocks. When an > error occurs within a nested TRY block, program control is transferred > to the CATCH block that is associated with the nested TRY block. > > To handle an error that occurs within a given CATCH block, write a > TRY…...CATCH block within the specified CATCH block. > > Errors that have a severity of 20 or higher that cause the Database > Engine to close the connection will not be handled by the TRY…CATCH > block. However, TRY…CATCH will handle errors with a severity of 20 or > higher as long as the connection is not closed. > > Errors that have a severity of 10 or lower are considered warnings or > informational messages, and are not handled by TRY…CATCH blocks. > > Attentions will terminate a batch even if the batch is within the > scope of a TRY…CATCH construct. This includes an attention sent by the > Microsoft Distributed Transaction Coordinator (MS DTC) when a > distributed transaction fails. MS DTC manages distributed transactions- Hide quoted text - > > - Show quoted text - If you set the serverity to 10 it works as expected also since 10 is treated as a informational error..
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar
SQL Agent job RAISEERROR roll-up JAW <jwilliam@aglresources.com> - 2011-10-31 11:51 -0700
Re: SQL Agent job RAISEERROR roll-up Erland Sommarskog <esquel@sommarskog.se> - 2011-10-31 22:43 +0100
Re: SQL Agent job RAISEERROR roll-up JAW <jwilliam@aglresources.com> - 2011-11-01 07:02 -0700
Re: SQL Agent job RAISEERROR roll-up JAW <jwilliam@aglresources.com> - 2011-11-01 09:39 -0700
Re: SQL Agent job RAISEERROR roll-up Erland Sommarskog <esquel@sommarskog.se> - 2011-11-01 22:17 +0100
csiph-web