Thursday, 27 April 2006

Purposely generating a record lock

Why? Is most probably what you're thinking.
I just use this technique for testing LOCKING check sql/reports.
Run this sql in 2 or more sessions -

-- open transaction
BEGIN TRANSACTION

-- run any select statement that brings back some data.
SELECT * FROM [DBO].[TABLENAME]

-- leave transaction open! Not commiting will cause a lock.
--COMMIT TRANSACTION

No comments: