locking users!

  •  

    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

  • You can use the nolock hint in your select statement or you can set the transaction isolation to read uncommitted.

  • 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

  • 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

  • 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