Supose that I have this table:
- Table(ID, Check, Description...)
Check is a bit, Description a string.
I would like to know that if I do this update:
update Table set Description = 'IsTrue' where Check = 1;
If a second process can change the Check value while the first process are doing the update, is it posible that for this row I get a description 'IsTrue' and the check is 0?
How does SQL Server work?
First case option:
The first process that want to update, block the row. Check if Check = 1 and update. In this case a second process can not change the value of the field because is blocked by the first process until the first process finish the update.
Second option:
The first process check if the row has Check value = 1. But don't block the row. Then a second process change the Check field to 0. The first process change the description, because the first process still think that Check is 1. this would be a problem.
If it occurs the second option, how can I ensure that the update is coherent?
Thank so much.