If I use the command SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
and then execute a stored procedure using the EXEC storedProcedureName
on the
The stored procedure will use the transaction isolation in effect when called.
If the stored procedure itself sets an explicit isolation level this will be reset when the stored procedure exits.
(Edit: Just checked and this is contrary to what BOL says "... it remains set for that connection until it is explicitly changed" but can be seen from the below)
CREATE PROC CheckTransLevel
AS
DECLARE @Result varchar(20)
SELECT @Result = CASE transaction_isolation_level
WHEN 0 THEN 'Unspecified'
WHEN 1 THEN 'ReadUncomitted'
WHEN 2 THEN 'Readcomitted'
WHEN 3 THEN 'Repeatable'
WHEN 4 THEN 'Serializable'
WHEN 5 THEN 'Snapshot'
END
FROM sys.dm_exec_sessions
WHERE session_id = @@SPID
PRINT @Result
GO
CREATE PROC SetRCTransLevel
AS
PRINT 'Enter: SetRCTransLevel'
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
EXEC CheckTransLevel
PRINT 'Exit: SetRCTransLevel'
GO
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
EXEC CheckTransLevel
EXEC SetRCTransLevel
EXEC CheckTransLevel
Results
ReadUncomitted
Enter: SetRCTransLevel
Readcomitted
Exit: SetRCTransLevel
ReadUncomitted