Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing timeouts

Status
Not open for further replies.

stevexff

Programmer
Mar 4, 2004
2,110
GB
I had to prove that a developer was handling deadlock timeouts correctly the other day. In order to generate a 'deadlock' The following bit of T/SQL was quite helpful.
Code:
BEGIN TRANSACTION
    UPDATE party SET somecolumn = 'something'
    WAITFOR DELAY '00:01'
COMMIT
Although you could argue that someone at Microsoft should be taken out and shot for making it legal to put a wait inside a transaction boundary like this, it is quite useful in this instance. It updates the record, then waits for a minute before committing it. This locks the row and gives you ample time to run your application to see if it handles DB timeouts correctly.

You could substitute a ROLLBACK for the COMMIT, but I haven't tested this...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top