I need a script to generate a deadlock | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

I need a script to generate a deadlock

Can someone help?
To generate a deadlock situation, create two tables—t1 and t2—each with one integer column, then in each table, insert a row with a value of 1. <br /><br />Define a trace with the following events: Lock<img src=’/community/emoticons/emotion-2.gif’ alt=’:D‘ />eadlock, Lock: Deadlock Chain, and relevant starting and completion statement events (RPC, SP, SQL), depending on the source you suspect<br /><br />_________<br />Satya SKJ<br />Moderator<br />SQL-Server-Performance.Com<br />
You need two QA session for this
— Connection 1
USE pubs
WHILE (1=1)
BEGIN
BEGIN TRAN
UPDATE employee SET lname=’Smith’ WHERE emp_id=’PMA42628M’
UPDATE authors SET au_lname=’Jones’ WHERE au_id=’172-32-1176′
COMMIT TRAN
END — Connection 2
USE pubs
WHILE (1=1)
BEGIN
BEGIN TRAN
UPDATE authors SET au_lname=’Jones’ WHERE au_id=’172-32-1176′
UPDATE employee SET lname=’Smith’ WHERE emp_id=’PMA42628M’
COMMIT TRAN
END should result in
Msg 1205, Level 13, State 2
Your server command (process id 12) was deadlocked with another
process and has been chosen as deadlock victim. Re-run your command taken from Inside SQL Server 7, but still valid
Frank
http://www.insidesql.de
Thank you i got a deadlock!
Congratulations, not many people are happy about this [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />Frank<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a>
]]>