The purpose of rollback is to "roll back" any and all data modifications have been done between BEGIN TRANSACTION and ROLLBACK in case if any unit of work fails to execute due to any errors.
Why are the COMMIT and rollback statements necessary?
A COMMIT statement is used to save the changes on the current transaction is permanent. A Rollback statement is used to undo all the changes made on the current transaction. ... If all the statements are executed successfully without any error, the COMMIT statement will permanently save the state.
What is the effect of rollback statement?
The effect of the rollback is as if that statement had never been run. This operation is a statement-level rollback. Errors discovered during SQL statement execution cause statement-level rollbacks. An example of such an error is attempting to insert a duplicate value in a primary key.