Catching errors in DBCC CHECKDB

  • Jesse Reich

    Hall of Fame

    Points: 3020

    Comments posted to this topic are about the item Catching errors in DBCC CHECKDB

  • ChiragNS

    One Orange Chip

    Points: 26137

    learnt something new.

    "Keep Trying"

  • This was removed by the editor as SPAM

  • Steve Vassallo

    SSCommitted

    Points: 1635

    Learned something today... Good question and keep them coming.

  • GabyYYZ

    SSCertifiable

    Points: 7913

    Wouldn't the backup fail because of a corrupt table?

    Gaby
    ________________________________________________________________
    "In theory, theory and practice are the same. In practice, they are not."
    - Albert Einstein

  • Jesse Reich

    Hall of Fame

    Points: 3020

    I actually tested the script out before I submitted it and the backup will happen. I used a corrupted database as the sample.

  • Ol'SureHand

    SSCrazy

    Points: 2744

    IMHO, the backup will happen regardless of whether or not the CATCH block is executed (i.e. regardless of DBCC raising an error).

    That is because the BACKUP command comes AFTER the END CATCH ....

    What is the purpose of the TRY/CATCH block if not to avoid crashing an execution sequence?

  • Ol'SureHand

    SSCrazy

    Points: 2744

    IMHO, the backup will happen regardless of whether or not the CATCH block is executed (i.e. regardless of DBCC raising an error).

    That is because the BACKUP command comes AFTER the END CATCH ....

    What is the purpose of the TRY/CATCH block if not to avoid crashing an execution sequence?

  • Ol'SureHand

    SSCrazy

    Points: 2744

    IMHO, the backup will happen regardless of whether or not the CATCH block is executed (i.e. regardless of DBCC raising an error).

    That is because the BACKUP command comes AFTER the END CATCH ....

    What is the purpose of the TRY/CATCH block if not to avoid crashing an execution sequence?

  • Ol'SureHand

    SSCrazy

    Points: 2744

    IMHO, the backup will happen regardless of whether or not the CATCH block is executed (i.e. regardless of DBCC raising an error).

    That is because the BACKUP command comes AFTER the END CATCH ....

    What is the purpose of the TRY/CATCH block if not to avoid crashing an execution sequence?

  • Ol'SureHand

    SSCrazy

    Points: 2744

    IMHO, the backup will happen regardless of whether or not the CATCH block is executed (i.e. regardless of DBCC raising an error).

    That is because the BACKUP command comes AFTER the END CATCH ....

    What is the purpose of the TRY/CATCH block if not to avoid crashing an execution sequence?

  • vk-kirov

    SSCertifiable

    Points: 7686

    Ol'SureHand (11/4/2009)


    IMHO, the backup will happen regardless of whether or not the CATCH block is executed (i.e. regardless of DBCC raising an error).

    That is because the BACKUP command comes AFTER the END CATCH ....

    What is the purpose of the TRY/CATCH block if not to avoid crashing an execution sequence?

    There is the RETURN statement after the RAISERROR:

    RAISERROR(@ErrorMessage, @ErrorSeverity, @ErrorState)

    RETURN

    This will interrupt the batch execution. See the link http://msdn.microsoft.com/en-us/library/ms174998.aspx:

    RETURN is immediate and complete and can be used at any point to exit from a procedure, batch, or statement block. Statements that follow RETURN are not executed.

  • Ol'SureHand

    SSCrazy

    Points: 2744

    Sorry, did not even notice the "RETURN" in the CATCH block.

    The eye did not see what the mind did not expect...

    The solution with the "executesql" full documentation to capture the DBCC output is a useful contribution, thank you.

  • Dude76

    Mr or Mrs. 500

    Points: 585

    The DBCC will not raise an exception but only messages ("informative"), so the TRY/CATCH will not prevent anything (and so the 'return' statement will not be reach).

    The Backup not fully verify integrity of database structure, just collect everything 'as it' and dump in bak file.

    Which are the cases/limits/frontiers between success or fail in backup process over a corrupted db ?

    edit: correct a false assert and so adjust the question 😉


    My MCP Transcript (ID : 692471 Access : 109741229)

  • SanjayAttray

    SSChampion

    Points: 13157

    Ol'SureHand (11/4/2009)


    IMHO, the backup will happen regardless of whether or not the CATCH block is executed (i.e. regardless of DBCC raising an error).

    That is because the BACKUP command comes AFTER the END CATCH ....

    What is the purpose of the TRY/CATCH block if not to avoid crashing an execution sequence?

    But, why post same question for five times?

    SQL DBA.

Viewing 15 posts - 1 through 15 (of 19 total)

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