I want to generate a deadlock for a test. Can anyone give me a method to do
this? So far, I have been able to generate only blocking locks and not ful
l deadlocks.
Thank you in advanceTry this:
In one QA session enter the following:
create table x (x int)
BEGIN TRANSACTION
insert into x values (1)
select * from x with (TABLOCKX)
In another QA session enter:
create table y (x int)
BEGIN TRANSACTION
insert into y values (1)
select * from x
Now go back to the first QA session and enter
select * from Y.
This will cause a deadlock.
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Greg G." <anonymous@.discussions.microsoft.com> wrote in message
news:CCBDB167-53FA-4659-A137-A8DF2FAC34A5@.microsoft.com...
> I want to generate a deadlock for a test. Can anyone give me a method to
do this? So far, I have been able to generate only blocking locks and not
full deadlocks.
> Thank you in advance|||Try this:
Run these transactions concurrently:
Tr-n One Tr-n Two
-- --
Begin transaction Begin transaction
Update table T1 Update table T2
Update table T2 Update table T1
Commit transaction Commit transaction
Thanks,
Lyudmila Fokina
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only
Disclamer: This posting is provided "AS IS" with no warranties, and confers
no rights.
"Greg G." <anonymous@.discussions.microsoft.com> wrote in message
news:CCBDB167-53FA-4659-A137-A8DF2FAC34A5@.microsoft.com...
> I want to generate a deadlock for a test. Can anyone give me a method to
do this? So far, I have been able to generate only blocking locks and not
full deadlocks.
> Thank you in advance|||Greg,
in one QA window:
USE northwind
GO
BEGIN TRANSACTION
update Region set RegionDescription = 'Northern' where regionid = 3
WAITFOR DELAY '00:00:10'
update Categories set Description = 'Seaweed and fish' where CategoryName
= 'Seafood'
commit TRANSACTION
in another:
USE northwind
GO
BEGIN TRANSACTION
update Categories set Description = 'Seaweed and fish' where CategoryName
= 'Seafood'
WAITFOR DELAY '00:00:10'
update Region set RegionDescription = 'Northern' where regionid = 3
commit TRANSACTION
HTH,
Paul Ibison|||Greg,
'Exploring Deadlocks'
asp" target="_blank">http://www.sqlservercentral.com/col...ion.
asp
Dinesh
SQL Server MVP
--
--
SQL Server FAQ at
http://www.tkdinesh.com
"Greg G." <anonymous@.discussions.microsoft.com> wrote in message
news:CCBDB167-53FA-4659-A137-A8DF2FAC34A5@.microsoft.com...
> I want to generate a deadlock for a test. Can anyone give me a method to
do this? So far, I have been able to generate only blocking locks and not
full deadlocks.
> Thank you in advance
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment