Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

THROW - 1 Expand / Collapse
Author
Message
Posted Wednesday, February 20, 2013 2:54 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 4:54 PM
Points: 8,689, Visits: 9,223
wolfkillj (2/20/2013)
venkat9.sql (2/20/2013)
wolfkillj (2/20/2013)
L' Eomot Inversé (2/20/2013)
Nice interesting question.

I really must upgrade and get SQL2012 so that I can start playing with this stuff instead of just reading about it.

If people have run the code and got 14 for erros state, what's going on? I would expect to see 14 only if THROW was called without any parameters (to rethrow the previous error).


I think people said they got severity level 14, not error state 14. They must be looking at the results of the SELECT in the CATCH block, which does show Level = 14, rather than the error message returned by the THROW statement, which always shows "Level 16" as its defined behavior.


Hey from BOL, I was infering that when THROW is used in a catch block without any parameters, it returns the level of the actual error raised in the try block and not 16...

Please let me know if I am right?


I don't think that's right. BOL specifies that THROW can be called without parameters only in a CATCH block, and also that severity is ALWAYS set to 16 with THROW.
Source: http://msdn.microsoft.com/en-us/library/ee677615.aspx

No, Venkat has it right.
BoL is quite clear that when throw is called without parameters it rethrows the error that caused the catch block to be entered. There's even an example on the BoL page you refrence that has it produciing severity 14. Severity 16 occurs whenever a new error is thrown (ie throw has parameters), but not when the existing error is rethrown (ie throw has no parameters); it would make no sense to supply severity 16 when re-throwing a caught error which has a different severity.


Tom
Post #1422325
Posted Thursday, February 21, 2013 4:14 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Thursday, June 12, 2014 4:19 AM
Points: 701, Visits: 1,145
Really have to get working on 2012. Don't have access to it currently and I can see the QotDs are moving more and more to it. Thanks for the question.
Post #1422495
Posted Monday, February 25, 2013 10:19 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 3:27 PM
Points: 21,631, Visits: 15,289
Nice Message



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1423693
Posted Monday, February 25, 2013 7:35 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, August 4, 2014 12:29 PM
Points: 1,812, Visits: 584
Nice question..
Thanks..
Post #1423846
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse