Figuring out the resource a lock in SQL Server 2000 affects
- by Michael Lang
I am adding a simple web-interface to show data from a commercial off the shelf (COTS) application. This COTS issues locks on any record the user is actively looking at (whether they intend to edit and update it or not).
I have found sp_lock and the Microsoft sp_lock2 scripts and can see the locks, so that's all well and good.
However, I cannot figure out how I can tell if a specific record I am about to update has been affected by one of these locks. If I submit the update request and there is in fact a lock, the web-interface will wait indefinitely until the user closes the window in the COTS.
How can I either:
a) determine before issuing an update that the record has been locked
OR
b) issue an update that will immediately return with a LOCKED status rather than indefinitely waiting on the COTS user to close their window on that record?