February 15, 2005 at 9:07 am
Hi all,
I have question that how can i lock database records such a way that if one user is accessing the record at that time other user can access the same record but can't make any changes it goes in read only mode! how can i perform that in SQL Server.
Thanks
February 15, 2005 at 9:14 am
You can use the nolock hint in your select statement or you can set the transaction isolation to read uncommitted.
February 15, 2005 at 9:17 am
is there a way that i can set up lock on database by itself that does it for any time user logs in and select data but can't make changes if another user is updating the same record?
Thanks
February 15, 2005 at 9:21 am
What do you call "accessing a record?"
When the first user has his application opened? or when the first user is executing a certain front-end transaction? or when the back-end complex transaction is executed? You most probably will need to set a transaction isolation level in your application, not on the database level.
Yelena
Regards,Yelena Varsha
February 15, 2005 at 11:06 pm
SET TRANSACTION ISOLATION LEVEL READ COMMITTED (Default setting)
begin transaction
select columns from the mytable (nolock)
update mytable
set ....
commit transction
This will prevent the other user executing the same batch to be blocked if he/she tried to update the table until the first user finishes with updating.
But the main probelm is that the 2nd user can see the dirty data on his/her screen.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply