Quote Originally Posted by skhanal View Post
You need to exit out of cursor loop after rollback transaction. Because after first rollback, the insert statement after else is not part of a transaction anymore.

Also if second row meets the condition rollback does not have corresponding begin tran and it fails with the error you saw.
Uh. How do I go about to exit the cursor? Do I need to close and deallocate the cursor after/before I exit?