In T-SQL, transactions are used to ensure that a series of operations are executed as a single unit of work. This means either all operations succeed (commit) or none of them take effect (rollback), preserving data integrity.

BEGIN TRANSACTION;

UPDATE Accounts SET Balance = Balance - 100 WHERE AccountId = 1;

UPDATE Accounts SET Balance = Balance + 100 WHERE AccountId = 2;

-- Commit if everything is successful

COMMIT;