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)
 Allow users to run SELECT while during TRANSACTION

Author  Topic 

khatri03
Starting Member

2 Posts

Posted - 2009-12-09 : 01:44:01
Assume that a user U1 is running a transaction on a table T1.
While the transaction is in process another user U2 tries to read from same table e.g T1.
Now what happens here sql server lock the table T1 for other users except than U1 for any kind of query execution.

Is it possible to allow user U2 to execute statement like SELECT * FROM T1 while transaction for user U1 is in process.

Please explain with examples.

vikky
Yak Posting Veteran

54 Posts

Posted - 2009-12-09 : 03:35:01
HI,

SELECT * FROM T1 with (nolock)

Thanks,
vikky.
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-09 : 03:57:54
quote:
Originally posted by vikky

HI,

SELECT * FROM T1 with (nolock)

Thanks,
vikky.




No lock's not using all the time.
It's for when you have concurrency issues.
you don't mind the chance of inaccurate data.

Selects can be run with no lock,
however all forms of data modification will take locks,
even if you specify the nolock hint.


Is equivalent to READUNCOMMITTED Transaction.
-------------------------
R...
Go to Top of Page

khatri03
Starting Member

2 Posts

Posted - 2009-12-09 : 03:59:37
Bundle of thanx vikky.

What will i have to do to prevent the user U2 to see the rows being updated. I mean how to exclude rows that are being by user U1 during transaction on table T1.

quote:
Originally posted by vikky

HI,

SELECT * FROM T1 with (nolock)

Thanks,
vikky.

Go to Top of Page
   

- Advertisement -