Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    12

    Talking Unanswered: Error handling - if update fails I need procedure to continue...

    Hi There,

    If an update in a stored procedure fails/errors (as in (a) below) the procedure will not continue with (b) - I need the code in (b) to run despite whether the previous update was successful or not - Any ideas?


    (a) if(@Data2 = 6)
    begin
    update
    SCHEDULE
    set
    Start_CallBack = getdate()
    where
    (Block = @Block)
    end


    (b) WHILE @Block_Count > 0
    BEGIN
    UPDATE BLOCK SET Status = @Block_Status
    END


    Any help will be greatly appreciated

  2. #2
    Join Date
    Dec 2002
    Location
    Antwerp, Belgium
    Posts
    227
    you can look in BOL for examples about error handling. For example, look for @@ERROR
    Johan

  3. #3
    Join Date
    Jan 2004
    Location
    Brazil
    Posts
    2

    XACT_ABORT

    You can try use a function called XACT_ABORT.

    When SET XACT_ABORT is ON, if a Transact-SQL statement raises a run-time error, the entire transaction is terminated and rolled back. When OFF, only the Transact-SQL statement that raised the error is rolled back and the transaction continues processing. Compile errors, such as syntax errors, are not affected by SET XACT_ABORT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •