If anything goes wrong with any of the grouped statements, all changes need to be aborted. The process of reversing changes is called rollback in SQL Server terminology. If everything is in order with all statements within a single transaction, all changes are recorded together in the database. In SQL Server terminology, we say that these changes are committed to the database.
see below simple query snippet
BEGIN TRANSACTION trans
BEGIN TRY
DELETE from Employee WHERE [Name] = 'Riya'
BEGIN COMMIT TRANSACTION trans
END
END TRY
BEGIN CATCH
print 'Error Occured'
BEGIN ROLLBACK TRANSACTION trans
END
END CATCH
see above snippet in which we have put try..catch in sql, if any error occurred when executing DELETE statement then transaction get rollbacked