question on locking ?

  • Hi All,

    Heard about readers can also block writers. Can anyone provide a demo example to prove this? I was under the impression that only writers can block readers.

    Secondly, will INSERT block a SELECT ?

    Thanks,

    Sam

     

  • fi you did something like this

    select * from mytable with (tablockx)

    then you have granted an exclusive lock against the entire table and no writer should get access

    you can also test this using a transaction

    Begin tran

    select * from mytable with (tablockx)

    then open a seperate window and try to update the table

    then go back to the original window and commit the tran, the update should work as soon as you do the commit

     

     

    MVDBA

  • Thank you.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply