I am trying to update table, which controlls application (application performs some select statements). I would like to update the table in transaction with isolation level set to read uncommited, so if application doesn't work as expected I can rollback transactions.
But following code doesn't work:
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
go
begin transaction
go
update [DB].[dbo].[Table]
set ID = ID - 281
where ID > 2
When I open another query window, I cannot query this table... I thought, that with such transaction level I would be able to query the table without rolling back/commiting transaction.
Transactions specify an isolation level that defines how one transaction is isolated from other transactions. Isolation is the separation of resource or data modifications made by different transactions. Isolation levels are described for which concurrency side effects are allowed, such as dirty reads or phantom reads.
Transaction isolation levels are a measure of the extent to which transaction isolation succeeds. In particular, transaction isolation levels are defined by the presence or absence of the following phenomena: Dirty Reads A dirty read occurs when a transaction reads data that has not yet been committed.
Serializable. This is the highest isolation level and prevents all possible types of concurrency phenomena in SQL Server, but on the other hand, the serializable level decreases performance and increases the likelihood of deadlocks.
Isolation level works in another way as you suppose.
You can only read uncommitted data, but others still cannot see what you done within transaction until you commit.
If you want to see uncommitted data from this transaction in your select you need to set
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
to this select
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With