with (tablock, holdlock)
BEGIN TRANSACTION
select top 1 *
from table1
with (tablock, holdlock)
-- You do lots of things here
COMMIT
This will hold the 'table lock' until the end of your current "transaction".
</p>
Lock a table while doing some stuff
Top comments (0)