Try catch in a transaction block or transaction in try catch block???

  • Jeff Moden (12/4/2011)


    I truly hope than no one makes the mistake of running that code without actually looking at it to see what it does. 😉

    Likewise, but not for the same reason.

    Msg 102, Level 15, State 1, Procedure EXAMPLE, Line 1

    Incorrect syntax near ')'.

    Msg 156, Level 15, State 1, Line 9

    Incorrect syntax near the keyword 'FOR'.

    Msg 137, Level 15, State 2, Procedure EXAMPLE, Line 11

    Must declare the scalar variable "@parameter".

    Msg 156, Level 15, State 1, Line 12

    Incorrect syntax near the keyword 'DROP'.

    Msg 102, Level 15, State 1, Procedure EXAMPLE, Line 26

    Incorrect syntax near 'DBNAME'.

    Msg 102, Level 15, State 1, Procedure EXAMPLE, Line 39

    Incorrect syntax near 'TRY'.

    Msg 102, Level 15, State 1, Procedure EXAMPLE, Line 51

    Incorrect syntax near 'DROPTABLE'.

    Msg 207, Level 16, State 1, Line 1

    Invalid column name 'NAME'.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hi Jeff/Gila Monster,

    It was just an example 😛 to help someone who posted a query in some other thread for "How to delete tables within a DB following some pattern in naming convention"

    I posted this here for GinaLuca to look and suggest me some template of using a Try..Catch within a proc to fetch error desc at Proc and Query level.

    From next time onwards I would make sure I test the query before posting it(to avoid being screwed by 2 masters). 😀

    Warm Regards,

    Ankit

    ______________________________________________________________________

    Ankit
    MCITP Database developer SQL 2008,MCTS Database Administration SQL 2008
    "Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose.
    You are already naked. There is no reason not to follow your heart.”

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

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