TRY...CATCH

  • ArnoKwetters (6/11/2015)


    I don't get the explanation.

    The ; after the END TRY produced the error.

    There is no statement between END TRY and BEGIn CATCH !

    The semicolon is a statement separator. So adding that after END TRY suggests that you end a statement and start a new one. (Albeit an "empty" statement - ;;; is valid syntax too!)

    For the record, I do not like this syntax. BEGIN and END can be followed by semicolon, BEGIN TRY, BEGIN CATCH and END CATCH can be followed by semicolon, but END TRY cannot. To be consistent, I would like to either omit semicolon on *every* BEGIN and END (but there are cases where that is not allowed), or include it after *every* BEGIN and END (but END TRY is the exception here).

    PS: You have been responding to lots of QotD topic lately. In most cases your posts are just a simple oneliner with no relevant content. You are of course free to do so, but in my opinion it doesn't add any value to the discussion. And it does increase the risk that people will simply ignore the SQLServerCentral "new post" notifications when they see your name, resulting in them also overlooking posts like this one, with a valid question, or posts where you do actually contribute new content to the discussion.

    There are a few regulars over here who will post a bunch of "+1" or "me too" or "good question" to about every thread they find. They already are on my ignore list. I hope you decide not to join them.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Thanks for your reply Hugo.

    It is indeed nasty that sometimes semicolons are not allowed and sometimes you have to use them !

    In the programming languages Delphi, C, C++ and C# is that more clear !

Viewing 2 posts - 31 through 31 (of 31 total)

You must be logged in to reply to this topic. Login to reply