T-SQL: create a lock

Bschelst/ August 14, 2017/ SQL-Server/ 0 comments

You can create a temporary lock in T-SQL for -for example- testing:

 
BEGIN TRAN   
SELECT 1 FROM TABLE WITH (TABLOCKX) WAITFOR DELAY '00:02:00'  ROLLBACK TRAN 
GO 
Share this Post

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*