GOTO Statement

  • Hello Everyone

    After diving head first into a multi database application. I am seeing the previous developer had used GOTO statements for errors.

    I thought I had read that GOTO was not going to be supported any longer. Does anyone have a site or docs that tell what items, objects, data types, syntax will no longer be supported and removed.

    Thanks

    Andrew SQLDBA

  • Clickable version of that link:

    Deprecated Database Engine Features in SQL Server 2008

    GOTO is part of the T-SQL language and probably always will be. It can be quite useful, and there's nothing wrong with it if not abused 🙂

    Paul

  • Seeing as this is in the SQL 2k5 forum.

    Personally if you have the time, I'd look at converting the GOTO's to TRY/CATCH blocks.

    Just so much simpler to be able to handle specific errors with every operation if necessary and write specific error handling right there with the potential error causer.

    If you don't have the time... the GOTO logic will never leave us :/



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • mtassin (1/14/2010)


    Seeing as this is in the SQL 2k5 forum.

    Personally if you have the time, I'd look at converting the GOTO's to TRY/CATCH blocks.

    Just so much simpler to be able to handle specific errors with every operation if necessary and write specific error handling right there with the potential error causer.

    If you don't have the time... the GOTO logic will never leave us :/

    TRY/CATCH shouldn't be the only error checking that you do (but should be in there!).

    You could run into a scenario where you run an update which executes fine but doesn't update any records. You might want some error checking to verify that *something* was updated if you require such a condition.

    Kev -=Conan The Canadian=-
    @ConanTheCdn

Viewing 5 posts - 1 through 4 (of 4 total)

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