Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how can commit transaction in other window

Author  Topic 

goodsolution
Starting Member

38 Posts

Posted - 2009-05-12 : 17:08:31
In query window 1:-

Begin transaction

insert into student (sd_id, name)
values (1, 'aaa')

insert into student (sd_id, name)
values (2, 'bbb')

-- Remember I didn't commit transaction

In query window 2:-

select * from student

Q1. What should I get from select statement in query window 2?
Q2. I mean to say, should it return the two values which were inserted in query window 1? I believe it shouldn't return as transaction didn't commit. I don't want touch query window 1. But I want to have those two values in query window 2. What should I write in query window 2 in order to get those two values? Any idea??

-Thanks

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-05-12 : 17:17:21
This will get the dirty data in the other window, otherwise the spid will get blocked until the transaction ends:
SELECT * FROM Student WITH (NOLOCK)
Go to Top of Page
   

- Advertisement -