Skip to content
Advertisement

Why does SQL Server read uncommitted data when the default isolation level is READ COMMITTED?

You have a dbo.inventory table and the itemsInStock is 10.

Let’s say you run this query:

begin tran

update dbo.inventory
set itemsInStock = 5 
where ID = 1

select * from dbo.inventory

(and you don’t commit the transaction)

Why is SQL Server reading a 5 if it hasn’t been committed yet and the default isolation is read committed?

Advertisement

Answer

Obviously a transaction needs to see everything it changed.

In this case the SELECT and the UPDATE are run in the same transaction, and therefor the changed that is visible to the current transaction (which did the change).

The isolation applies to other transactions that read from that table.

6 People found this is helpful
Advertisement