sql-server-2005dirtyread

Will the select interfered by DML


When using clean read (Read committed)... Will a select query be interfered by another DML (Insert, Update, Delete) query ? If yes, can you provide some cases. I'm using SQL Server 2005.

What is the possiblity the below query will be yield incorrect data. The query does not use any joins, it just fetches data from a single table based on some creteria.

Select PracticeCode, AccountNo, ProcCd, Modifier , ChargeDos, Paid as Amt, CreatedDate,
       case When Paid > 0 then 'P' 
              When Paid = 0 and WrittenOff = DueAmt then 'A'
              Else 'O' 
       End as Status
     From Trn_Postings
     Where CreatedDate between @StartDateTime and @EndDateTime
                  and ManualOverride not in ('F','S','X','G','O')

Solution

  • Read committed isolation level uses shared locks at the row level to avoid reading dirty data. However, since the locking is at the row level, other rows may change before the transaction completes, resulting in nonrepeatable reads or phantom data.

    See the Microsoft documentation on SET TRANSACTION ISOLATION LEVEL for additional details and this blog post for a good example.