How to create a shared lock blocking an intent exclusive lock

Posted by FremenFreedom on Server Fault See other posts from Server Fault or by FremenFreedom
Published on 2010-10-13T14:26:54Z Indexed on 2011/03/08 8:12 UTC
Read the original article Hit count: 609

As I understand it, a SELECT statement will place a shared lock on the rows that it will return. While that SELECT is running, if an UPDATE statement comes along and needs to grab an intent exclusive lock then that UPDATE statement will need to wait until the SELECT statement releases its shared locks.

I am trying to test this SELECT shared lock thing by doing a BEGIN TRAN and then running a SELECT, not COMMITing, and then running an UPDATE in another session on the exact same row. The UPDATE worked fine -- no lock, no wait. So this must not be a valid way to simulate a shared lock blocking an intent exclusive lock? Can you give me a scenario where I can create a lock with a SELECT that would force an UPDATE to wait?

I'm working with SQL Server 2000 and 2005 across a linked server: the table is on the 2005 instance, the select is happening on 2000, and the update is executed from 2005. All in SSMS 2005.

© Server Fault or respective owner

Related posts about sql-server-2005

Related posts about sql-server-2000