We are trying to test our new software here which is based on SQL 2005. We want to see how it will respond when one of the tables which the software is using during insert/update gets locked.
Is there a way in SQL 2005 we can simulate this? so that we can see how we can handle the error on the front end?
In SQL Server Management Studio, run this TSQL script (set timeout to whatever suits you)
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
UPDATE table
SET ColumnName = ColumnName
WAITFOR DELAY '00:02:00' -- 2 minutes hh:mm:ss
-- Run your test while table is locked and delay is counting down
ROLLBACK TRANSACTION
Using another session,
Do a BEGIN TRANSACTION
Call UPDATE table set columnName = columnName
Run your test
Verify your results
COMMIT TRAN / ROLLBACK TRAN
the transaction
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With