statement of problem:
In order to avoid concurrent problems, it is an unexpected problem that the problem is unexpected.
Suppose there is a table T1
There is only one field field2 varchar (20) type.
He repeatedly executed a short code:
Set Transaction Isolation Level Serializable
Begin TRAN
SELECT * FROM T1
Waitfor delay '00: 00: 30'
INSERT INTO T1 VALUES ('123')
IF @@ error = 0
Commit TRAN
Else
Rollback TRAN
problem:
1. Don't hurry to implement this code, what problems do you have in the same time as many people in this code?
2. He violates the principles of database transaction design
After the solution, you will find that the business is improper, it is easy to have problems, or even serious consequences.