Forcing a query timeout in SQL Server

前端 未结 4 1415

We have had an issue with a block of code that responds poorly in the face of slow databases (It craps the bed on a query timeout). We have created a patch, and are in the p

4条回答
  •  再見小時候
    2020-11-29 17:53

    run this and then try your insert...

    select * from yourTable with (holdlock,tablockx)
    

    here, you can lock it for 5 minutes:

    BEGIN TRANSACTION
    
    SELECT * FROM yourTable WITH (TABLOCKX, HOLDLOCK)
    
    WHERE 0 = 1
    
    WAITFOR DELAY '00:05'
    
    ROLLBACK TRANSACTION
    

提交回复
热议问题