troubleshooting Question

Conditional TRY..CATCH block

Avatar of RICuser
RICuserFlag for United States of America asked on
Microsoft SQL ServerDB Dev ToolsMicrosoft SQL Server 2008
3 Comments1 Solution546 ViewsLast Modified:
Hello Experts,
I am trying to include some logic in a maintenance job step (MS SQL Server 2005-2008)
The job step executes a daily maintenance stored procedure in the database.
The goal is if the stored procedure completes successfully to add logic to reset a maintenance bit (Boolean 0 or 1) in a table in the same database, where 0 means no users are allowed on the database and 1 opens the database to users.
This is important because if there are user connections during the execution of the SP the maintenance will fail, so it is important for the "maintenance bit" as I call it,  to be switched OFF prior , and ON after the successful run of the maintenance SP.
I am trying to incorporate this within the TRY..CATCH block, not sure how.
Please see attached and come up with your suggestions ans examples as to how to accomplish this.

Thank you,
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros