The garden has a very good article about SQL Server transaction isolation, feeling a lot of the introduction from the concept, for those beginners, see the touch of understanding is profound, so no longer repeat, the emphasis is on the example demonstration above.
The first explanation is what transaction isolation is, and the isolation level of a transaction controls how it affects other transactions and is affected by other firms.
1. READ UNCOMMITTED, which results in dirty reads (which can read changes not committed by other transactions) and non-repeatable reads (data read by the transaction is modified by another transaction, inconsistent when read again)
Class
CREATE TABLE tranlevel (k int IDENTITY (1,1), Val int)
insert into Tranlevel (val) VALUES (1)
inserts into Tranlevel (v AL) VALUES (2)
INSERT into Tranlevel (val) VALUES (3)
Execute Query1 First, and then create a new query to execute immediately Query2
Query1:
BEGIN TRAN Query1
--Modify
UPDATE tranlevel SET val = 9 in a transaction- ' Wait 10 seconds while transaction 2 runs '
WAITFOR DELAY ' 00:00:10 '
--Do not commit changes, ROLLBACK TRANSACTION
ROLLBACK TRAN Query1
Query2:
--Sets the current session transaction isolation level for uncommitted read
set TRANSACTION isolation levels READ UNCOMMITTED
begin TRAN Query2
SELECT ' transaction 2 start concurrent execution, Read to Transaction 1 modified but not submitted data, is dirty read '
select * from Tranlevel
select ' Transaction 2 wait 10 seconds, let transaction 1 Finish '
WAITFOR DELAY ' 00:00:10
' The result of the select ' two reads is inconsistent and is not repeatable read '
select * from Tranlevel
COMMIT TRAN Query2
Here's a look at the results of Query2 execution:
The result is obvious, if the transaction isolation level is set to uncommitted read, it can cause dirty read and non repeatable reads, the least restrictive of these transaction isolation levels, and the smallest resource allocated by SQL Server.