|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 1:35 AM
Points: 357,
Visits: 706
|
|
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?
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Thursday, June 13, 2013 8:50 PM
Points: 3,208,
Visits: 4,178
|
|
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.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 1:35 AM
Points: 357,
Visits: 706
|
|
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.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, March 18, 2013 7:52 PM
Points: 280,
Visits: 88
|
|
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)
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 15, 2013 2:43 PM
Points: 3,924,
Visits: 1,554
|
|
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.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 1:35 AM
Points: 357,
Visits: 706
|
|
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...
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, April 11, 2013 12:58 AM
Points: 174,
Visits: 555
|
|
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!
|
|
|
|
|
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
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Saturday, April 06, 2013 12:20 AM
Points: 649,
Visits: 263
|
|
| That was a good question!
|
|
|
|