Home Forums SQL Server 2005 Development Try Catch alters behaviour of existing procedures RE: Try Catch alters behaviour of existing procedures

  • The Dixie Flatline (7/7/2010)In your example, change the error severity to 9 instead of 16 and you get the consistent behavior you are after. The various behaviors based on error severity are by design. In some cases a procedure cannot and should not proceed after a severe error.

    I cannot control the severity level of errors

    that example is contrived to prove that the codepath is altered

    in real life it will be a DML statement that is raising the error

    update dbo.Table

    set [Field] = 'value'

    where [OtherField] = 'otherValue'

    if @@error <> 0 or @@rowcount <> 1 goto label_do_something --<< when this SP is called from another SP within a TRY block it may not reach this line