What are the ways to code efficient transactions?
Do not ask for an input from a user during a transaction.
Get all input needed for a transaction before starting the transaction.
Transaction should be atomic
Transactions should be as short and small as possible.
Rollback a transaction if a user intervenes and re-starts the transaction.
Transaction should involve a small amount of data as it needs to lock the number of rows involved.
Avoid transactions while browsing through data.
SQL Server Interview Questions · · · ·