Catching errors in DBCC CHECKDB

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

  • learnt something new.

    "Keep Trying"

  • This was removed by the editor as SPAM

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

  • 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

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

  • 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?

  • 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?

  • 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?

  • 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?

  • 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 (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.

  • 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.

  • 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)

  • 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 18 total)

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