SQL Server Interview Question #245

What is a lost update?

Advanced Transactions & Concurrency Senior Advanced

Detailed Explanation

A lost update occurs when two transactions read the same data, both make changes, and one transaction's later write unintentionally overwrites the other's committed change.

Optimistic concurrency tokens, suitable locking strategies, atomic UPDATE statements, or stronger transaction semantics can prevent lost updates.

For web applications, blindly updating a row using only its primary key after presenting an edit form can create this problem when multiple users edit the same record concurrently.