SQL Isolation Levels EX 3 Connection 2

Isolation Levels EX 3 Connection 2


-- Batch 2 
USE PUBS
GO

-- Batch 3
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
GO
BEGIN TRAN

SELECT title FROM titles 
WHERE title_id LIKE 'BU%'
GO

-- Batch 5
-- execute the same SELECT again

SELECT title FROM titles 
WHERE title_id LIKE 'BU%'
GO
COMMIT TRAN
-- Now do the same thing, 
-- but with SERIALIZABLE isolation

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE 
GO
BEGIN TRAN
SELECT title FROM titles 
WHERE title_id LIKE 'BU%'
GO

-- Batch 7
SELECT title FROM titles 
WHERE title_id LIKE 'BU%'
COMMIT TRAN
GO

-- Batch 9
-- Now notice that the second 
-- new title has been inserted 
-- after the COMMIT TRAN
SELECT title FROM titles 
WHERE title_id LIKE 'BU%'
GO