Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Catching errors in DBCC CHECKDB Expand / Collapse
Author
Message
Posted Wednesday, November 4, 2009 11:00 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Sunday, November 2, 2014 7:52 PM
Points: 371, Visits: 717
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?
Post #814019
Posted Thursday, November 5, 2009 2:22 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, May 9, 2014 12:47 AM
Points: 3,448, Visits: 4,407
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.
Post #814076
Posted Thursday, November 5, 2009 6:54 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Sunday, November 2, 2014 7:52 PM
Points: 371, Visits: 717
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.
Post #814204
Posted Thursday, November 5, 2009 8:27 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, October 17, 2014 8:46 AM
Points: 280, Visits: 90
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)
Post #814300
Posted Thursday, November 5, 2009 9:11 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, July 17, 2014 10:56 AM
Points: 3,924, Visits: 1,607
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.
Post #814344
Posted Thursday, November 5, 2009 7:37 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Sunday, November 2, 2014 7:52 PM
Points: 371, Visits: 717
Well, there was a timeout each time I clicked "Post".
So I did not realise the message was being posted regardless ... sorry 'bout that! And there is no "delete post" button I could see...
Post #814650
Posted Friday, November 6, 2009 4:43 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 18, 2014 4:04 AM
Points: 176, Visits: 567
Thanks for this! I would've lost time figuring out the T-SQL for backup for our database (SQL2k05) and Finance (SQL2K) server.

With this script, I could use this for db transfer to removable drive; for our DRP.

Thanks, thanks, thanks!
Post #814824
Posted Saturday, November 7, 2009 6:58 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, May 10, 2012 9:49 AM
Points: 800, Visits: 1,759
Thanks, good question.
Piotr


...and your only reply is slàinte mhath
Post #815404
Posted Thursday, November 12, 2009 9:25 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, December 11, 2014 5:11 AM
Points: 654, Visits: 267
That was a good question!
Post #817928
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse