Hello, I need some suggestions about stopping the execution of a script when an error occurs. Let's say we have several blocks of codes and these blocks are try catch blocks. I want my script to execute in such a way that when an error occurs in say 6th block, the execution should stop there and throw an error. It should not rollback 5th,4th,3rd,2nd and 1st block, but should rollback the 6th block of codes. I am using sql server 2008 express edition. Your help will be appreciated.
I came to know the answer for it. Using RETURN would exit or break the execution when error occurs in the script. begin try; begin tran; -- enter code end try begin catch print error_message() RETURN end try