SQL Server Read Uncommited SQL Azure

vlurs2pr  于 2023-05-16  发布在  其他
关注(0)|答案(3)|浏览(108)

I am running following SQL statement on SQL Azure database:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;  
BEGIN TRANSACTION;  

UPDATE Project SET Name = 'NewLim2' WHERE Projectid = 403179
WAITFOR DELAY '00:00:10'

COMMIT TRANSACTION

Then during the 10 seconds delay I use another connection which performs following select:

SELECT * FROM Project WHERE Projectid = 403179

But its result is 'NewLim' as Name (original value) and 'NewLim2' is after the committing. When I run transaction with Read uncommitted I suppose that it will read updated value even before commit. Or am I missing something?

hk8txs48

hk8txs481#

You need

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;

before your Select statement.

hc8w905p

hc8w905p2#

Just wanted to point out,Isolation levels are only for select Statements,below statement you have in your update doesn't make any sense

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;

Reason why you didn't got uncommitted data was due not having required Isolation level in your select as mentioned in answer

bvjveswy

bvjveswy3#

Can't you just make your query, ending by "WITH UR" like we can do in e.g. DB2?

So:

SELECT * FROM Project WHERE Projectid = 403179 WITH UR

相关问题