SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Catching errors in DBCC CHECKDB


Catching errors in DBCC CHECKDB

Author
Message
Ol'SureHand
Ol'SureHand
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1249 Visits: 720
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
vk-kirov
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4860 Visits: 4408
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
Ol'SureHand
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1249 Visits: 720
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
Dude76
Old Hand
Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)

Group: General Forum Members
Points: 350 Visits: 94
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 Wink


My MCP Transcript (ID : 692471 Access : 109741229)
SanjayAttray
SanjayAttray
SSCertifiable
SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)

Group: General Forum Members
Points: 6915 Visits: 1619
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.
Ol'SureHand
Ol'SureHand
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1249 Visits: 720
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...
Open Minded
Open Minded
Say Hey Kid
Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)

Group: General Forum Members
Points: 674 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!
Piotr.Rodak
Piotr.Rodak
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4196 Visits: 1761
Thanks, good question.
Piotr

...and your only reply is slàinte mhath
VM-723206
VM-723206
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1288 Visits: 267
That was a good question!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search