HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Do I add read committed after SET TRANSACTION ISOLATION LEVEL SERIALIZABLE?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
afterisolationcommittedreadlevelserializabletransactionsetadd

Problem

Inside a stored procedure, I have the following : ( sql server 2008 )

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
 BEGIN TRANSACTION getStuff
 BEGIN TRY 
    /*  some selects, updates, etc, etc. */
    ....
    COMMIT TRANSACTION getStuff
 END TRY
 BEGIN CATCH 
   ...
 END CATCH


Since this is transaction based, my thought was the rest of the database connections will not be affected by the SERIALIZABLE.

Do I need to implicitly set isolation level to read committed after my commit? Will this adversely effect other connections between my application server and database server?

Solution

No you do not have to implicitly set isolation level back to read committed.

From books online.


If you issue SET TRANSACTION ISOLATION LEVEL in a stored procedure or
trigger, when the object returns control the isolation level is reset
to the level in effect when the object was invoked. For example, if
you set REPEATABLE READ in a batch, and the batch then calls a stored
procedure that sets the isolation level to SERIALIZABLE, the isolation
level setting reverts to REPEATABLE READ when the stored procedure
returns control to the batch.

Context

StackExchange Database Administrators Q#171425, answer score: 5

Revisions (0)

No revisions yet.