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


TRY...CATCH


TRY...CATCH

Author
Message
venkat9.sql
venkat9.sql
SSC Veteran
SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)

Group: General Forum Members
Points: 286 Visits: 260
Comments posted to this topic are about the item TRY...CATCH

___________________________________________________________________
If I can answer a question then anyone can answer it..trying to reverse the logic.. Hehe
Danny Ocean
Danny Ocean
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: 1848 Visits: 1549
Good one. New thing come to know.

Thank. Keep it up !!! :-)

Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
www.GrowWithSql.com
kapil_kk
kapil_kk
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3594 Visits: 2766
Good question :-):-)

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Bangla
Bangla
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1743 Visits: 180
Nice....
Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13141 Visits: 12176
Good question, but the explanation falls a bit short. I was very disappointed when I first saw this behaviour. A semicolon is a statement terminator and should be used after every statement - but apparently, END TRY is not considered a statement by this logic. So the semicolon after END TRY is not interpreted as terminating the END TRY, but as terminating a dummy, zero-length statement. (They exist. Try typing a bunch of semicolons and hit execute - it will complete without errors).

In short - just after I had learned myself to consistently semicolon-terminate every statement, I now have to leanr myself NOT to do that for at least one statement (END TRY).


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Bob JH Cullen
Bob JH Cullen
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1030 Visits: 786
I selected the syntax error option but not for the reason stated. The question states SQL 2005 and higher, but THROW evidently makes its appearance with SQL 2012, so is invalid syntax is the right answer for 2005, 2008, 2008 R2, eh?
So, another case of "it depends".
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10982 Visits: 7326
Hugo Kornelis (4/2/2013)
Good question, but the explanation falls a bit short. I was very disappointed when I first saw this behaviour. A semicolon is a statement terminator and should be used after every statement - but apparently, END TRY is not considered a statement by this logic. So the semicolon after END TRY is not interpreted as terminating the END TRY, but as terminating a dummy, zero-length statement. (They exist. Try typing a bunch of semicolons and hit execute - it will complete without errors).

In short - just after I had learned myself to consistently semicolon-terminate every statement, I now have to leanr myself NOT to do that for at least one statement (END TRY).


+1

what a gotcha...

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Andrew Watson-478275
Andrew Watson-478275
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1909 Visits: 2719
Hugo Kornelis (4/2/2013)
Good question, but the explanation falls a bit short. I was very disappointed when I first saw this behaviour. A semicolon is a statement terminator and should be used after every statement - but apparently, END TRY is not considered a statement by this logic. So the semicolon after END TRY is not interpreted as terminating the END TRY, but as terminating a dummy, zero-length statement. (They exist. Try typing a bunch of semicolons and hit execute - it will complete without errors).

In short - just after I had learned myself to consistently semicolon-terminate every statement, I now have to leanr myself NOT to do that for at least one statement (END TRY).

Thanks for clearing that up Hugo - I was scratching my head trying to work out where the extra statement between the try and the catch was.
manik_anu
manik_anu
Mr or Mrs. 500
Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)

Group: General Forum Members
Points: 512 Visits: 312
+1... nice question to learn about TRY-Catch....





Learn new things every where
Manik

Manik
You cannot get to the top by sitting on your bottom.
manik_anu
manik_anu
Mr or Mrs. 500
Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)Mr or Mrs. 500 (512 reputation)

Group: General Forum Members
Points: 512 Visits: 312
Hugo Kornelis (4/2/2013)
Good question, but the explanation falls a bit short. I was very disappointed when I first saw this behaviour. A semicolon is a statement terminator and should be used after every statement - but apparently, END TRY is not considered a statement by this logic. So the semicolon after END TRY is not interpreted as terminating the END TRY, but as terminating a dummy, zero-length statement. (They exist. Try typing a bunch of semicolons and hit execute - it will complete without errors).

In short - just after I had learned myself to consistently semicolon-terminate every statement, I now have to leanr myself NOT to do that for at least one statement (END TRY).



+1... nice....

Manik
You cannot get to the top by sitting on your bottom.
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