SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Transaction Isolation question


Transaction Isolation question

Author
Message
sunny.tjk
sunny.tjk
SSC-Addicted
SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)

Group: General Forum Members
Points: 493 Visits: 1344
The isolation level of the database that I'm running the query on is READ COMMITTED.
I ran query 1 and query 2.
Query 1 is
IF OBJECT_ID('tempdb..##my_name') IS NOT NULL
BEGIN
DROP TABLE ##my_name;
END;

CREATE TABLE ##my_name
(
id INT,
first_name VARCHAR(20)
);

INSERT INTO ##my_name (id, first_name)
VALUES (1, 'dexter');

BEGIN TRAN

UPDATE ##my_name
SET first_name = 'derek'
WHERE id = 1;



Query 2 is
SELECT * FROM ##my_name WITH (NOLOCK);
SELECT * FROM ##my_name;

My question is that I was expecting "SELECT * from ##my_name" to hang without generating results because I haven't ran COMMIT TRAN or ROLLBACK TRAN yet. But I'm getting results as dirty read.

I'm little confused here. Can someone help me out?
Suresh B.
Suresh B.
SSCommitted
SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)

Group: General Forum Members
Points: 1950 Visits: 5326
You should run the Query 2 on a different session (query window).
GilaMonster
GilaMonster
SSC Guru
SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)

Group: General Forum Members
Points: 88236 Visits: 45277
You never block yourself. If you have just run a data modification, in that same session you can always see the data you modified.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


sunny.tjk
sunny.tjk
SSC-Addicted
SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)

Group: General Forum Members
Points: 493 Visits: 1344
Feeling stupid.

Thanks guys! Problem solved..
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search