SQL Isolation Levels EX 2 Connection 2

Isolation Levels EX 2 Connection 2


-- Batch 2
USE PUBS
GO

-- Batch 3
UPDATE authors 
SET au_lname='Doe' 
-- Make sure no Smith or Jones

-- Change the transaction isolation
-- level and then verify there are 
-- no authors named 'Smith'
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
GO
BEGIN TRAN
SELECT au_lname FROM authors 
WHERE au_lname='Smith'
GO

-- Batch 5
SELECT au_lname FROM authors 
WHERE au_lname='Smith'
GO
                            
COMMIT TRAN
GO
-- Now do the same thing, 
-- but with REPEATABLE READ isolation

SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
GO

BEGIN TRAN
SELECT au_lname FROM authors 
WHERE au_lname='Smith'
GO 

-- Batch 7
SELECT au_lname FROM authors 
WHERE au_lname='Smith'
COMMIT TRAN
GO

-- Batch 9
-- Now notice that Jones updates 
-- have been done
SELECT au_lname FROM authors 
GO