![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
JAW (jwill... (AT) aglresources (DOT) 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... (AT) sommarskog (DOT) 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 |
#4
| |||
| |||
|
|
On Oct 31, 5:43*pm, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote: JAW (jwill... (AT) aglresources (DOT) 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... (AT) sommarskog (DOT) 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 - |
#5
| |||
| |||
|
|
If you set the serverity to 10 it works as expected also since 10 is treated as a informational error.. |
![]() |
| Thread Tools | |
| Display Modes | |
| |