Click here to Skip to main content
15,885,366 members
Articles / Database Development / SQL Server

How to Prevent When a Transaction Accidentally Overwrites Modified Data

Rate me:
Please Sign up or sign in to vote.
4.91/5 (16 votes)
30 Apr 2017CPOL14 min read 23.8K   520   17  
This article explains the problem, when another transaction (concurrent or not) accidentally overwrites previously modified data and how to prevent this from happening.
The purpose of this article is to explain how to prevent a lost update from occurring in SQL Server. The method is done using row version checking which extends the check of the data version outside the transaction scope. It looks at: Why row version check is often required even though pessimistic locking is used, how to utilize rowversion to implement this check, how to check the rowversion in a procedure, how to force the client program to provide correct rowversion using a trigger, and how the check can be done using Entity Framework.

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Europe Europe
Biography provided

Comments and Discussions