How do you handle transactions in T-SQL?
Loading
How do you handle transactions in T-SQL?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sangeetha SPosted Jul 15, 2025, 6:17 AM
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;