Search code examples
sqlsql-serverdatabasetransactionsisolation-level

Isolation Levels - SQL Server


If I'm using

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

Do I need to wrap the query in a transaction

e.g.

BEGIN TRAN
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SELECT * FROM
T1
COMMIT

Or can I just have a normal query?

Also, is there any benefit to including SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED and WITH (NOLOCK). I understand that one is for the table level and one is for the whole connection level. But is there any benefit to having both?

Such as:

    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
    SELECT * FROM
    T1 WITH (NOLOCK)

Solution

  • Always we executes procedure of INSERT, UPDATE and DELETE transaction with READ COMMITTED ISOLATION LEVEL. If we need dirty data from any table then it helps. Because Transaction is defined with READ COMMITTED and table return dirty reads using WITH(NOLOCK) in JOIN Query.