October 9, 2009 at 9:57 am
Hello all,
I have a stored procedure with a series of update statements.
--Update statement 1
UPDATE.....
--Update statement 2
UPDATE.....
If update 1 fails I still want update 2 to run. Is this possible?
October 9, 2009 at 10:22 am
Emily,
My recommendation would be to encapsulate each Update in a BEGIN TRY...END TRY / BEGIN CATCH...END CATCH block.
If you are on a pre-SQL 2005 install, this won't be available to you so you'll have to settle for checking the error code after each statement and hoping you don't run into a statement that ends the batch/proc before error-checking can be done.
October 9, 2009 at 10:54 am
BEGIN TRY functionality is awesome, but alas I am on 2000.
October 9, 2009 at 11:16 am
If you don't mind doing a bit of reading, Erland Sommerskog has one of the better write-ups on SQL Server error handling:
http://www.sommarskog.se/error-handling-I.html
About a third of the way down the section "When does SQL Server take which action?" has a table with the error behavior of a number of common errors, most of which are probably applicable to your UPDATE statement(s).
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy