SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


THROW - 1


THROW - 1

Author
Message
Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25427 Visits: 12494
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

(Bob Brown)
(Bob Brown)
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1051 Visits: 1145
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.
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: General Forum Members
Points: 64681 Visits: 18570
Nice Message



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


SQL RNNR

Posting Performance Based Questions - Gail Shaw

pchirags
pchirags
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2701 Visits: 616
Nice question..
Thanks..
SQL-DBA-01
SQL-DBA-01
SSCrazy Eights
SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)

Group: General Forum Members
Points: 8031 Visits: 3555
why not error level = 14 and state =1 ??

Thanks.
Arno Kwetters
Arno Kwetters
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1791 Visits: 380
I never did a create + insert with a catch.
But that works. If you build it in dynamic SQL it can be worthfull.
Thanks.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search