– open a command line and connect to the server (sqlcmd -E -S {Server} -d {db})
 – execute “begin tran”
 – execute “update {table} set {field}={value} [{where clause}]
 – execute your code to verify it properly handles the timeout
 – execute “rollback tran”
A better way (found on stackoverflow), that can be automated: execute the following statement in your test setup method:
BEGIN TRANSACTION 
SELECT 1 FROM {table} WITH (TABLOCKX, HOLDLOCK) WHERE 0 = 1 
WAITFOR DELAY '00:05' 
ROLLBACK TRANSACTION 
Advertisements