With SQL Server\'s transaction isolation levels, you can avoid certain unwanted concurrency issues, like dirty reads and so forth.
The one I\'m interested in right n
The example in the book is of Clerk A and Clerk B receiving shipments of Widgets.
They both check the current inventory, see 25 is in stock. Clerk A has 50 widgets and updates to 75, Clerk B has 20 widgets and so updates to 45 overwriting the previous update.
I assume she meant this phenomena can be avoided at all isolation levels by Clerk A doing
UPDATE Widgets
SET StockLevel = StockLevel + 50
WHERE ...
and Clerk B doing
UPDATE Widgets
SET StockLevel = StockLevel + 20
WHERE ...
Certainly if the SELECT
and UPDATE
are done as separate operations you would need repeatable read
to avoid this so the S
lock on the row is held for the duration of the transaction (which would lead to deadlock in this scenario)