ROLLBACK TRANSACTION (TSQL Statement)

Discards all the changes made by the current explicit transaction.

Syntax

ROLLBACK { TRAN | TRANSACTION } 

Remarks

If @@TRANCOUNT is 0, there is no active transaction. An error is raised.

Else, ROLLBACK TRANSACTION will cancel all the changes recorded by the current transaction since the outermost BEGIN TRANSACTION statement, and @@TRANCOUNT counter will be set to 0.

Note that ROLLBACK TRANSACTION doesn’t terminate the batch and the program continues executing normally. If you want the program to terminate, you must put a RETURN after the ROLLBACK TRANSACTION statement.

Most of the times, you don’t need to use ROLLBACK TRANSACTION.
It is easier to raise an error with THROW. The batch will abort immediately and an automatic rollback will be performed, discarding all the changes.

More Information

See BEGIN TRANSACTION for more information.

RSQL, a simple alternative to Microsoft SQL Server