This may be very basic question. If we open a sql transaction with “Begin Transaction”, is commit transaction or rollback is mandatory…?
I have a scenario where i need to exit the SP when a row exists in if statement fails. This if statement is currently inside the transaction scope..
Thanks in advance!
Regards
Bala
It’s not mandatory, the transaction will stay open until an error or the connection is closed. But you don’t want to do this, you may be blocking other users for a very long time.
You should
COMMIT TRANSACTIONorROLLBACK TRANSACTIONat the earliest opportunity.