MS SQL Server 2008 R2
Say we have the following tables:
**MoneyTransactions**
- Amount (int)
- CustomerId (int)
...
Customers
- Id (int)
- balance (int)
...
Is the following operation thread safe if execute 100 times simultaniously?:
INSERT INTO Transactions(Amount, CustomerId, ...) Values(@myAmount, @customerId, ...)
UPDATE Customers SET Balance = Balance + @myAmount WHERE Id = @customerId
Is my update executed atomically or can simultanious executions interfer and make the balance corrupt comparred to the sum of Amounts in Transactions?
I would like to avoid a BEGIN TRAN/COMMIT TRAN
if possible.