22. Transactions: BEGIN, COMMIT, ROLLBACK
Idea: Transactions group changes so they succeed or fail together. BEGIN TRAN starts, COMMIT saves, ROLLBACK undoes.
Shape
BEGIN TRANSACTION; UPDATE Products SET Price = 12 WHERE Name = 'Book'; COMMIT;
Multiple Statements
Multiple changes in one transaction.
Placeholders for Examples
Coming soon: updating products in a transaction.
Advanced Deep Dive ADVANCED
ACID Properties: Transactions are Atomic, Consistent, Isolated, Durable.
Savepoints: Use SAVE TRAN for partial rollbacks.
Implicit Transactions: Some settings start transactions automatically.
Locks: Transactions hold locks; long transactions can block others.
Error Handling: Use TRY...CATCH for safe rollbacks.