November 5, 2014 at 8:21 pm
Hi Guy,
Do you have sample coding for handling deadlock.
November 6, 2014 at 2:27 am
Hi and welcome to the forum.
Further on Stewart's answer, have a look at this article, Detecting and Ending Deadlocks
Avoiding deadlocking is best done by design, making certain that resources are consistently requested in the same order. In addition to this, there are quite few "tools" and methods such as proper indexing, covering indexes, deadlock priority, isolation levels, transaction construction etc..
😎
November 6, 2014 at 3:30 am
I have find the deadlock issue on updating but i want to the the processing repeat when dead lock occur.
November 6, 2014 at 5:45 pm
Thanks:-), Anther question. How to write a SQL coding to check the table is no locking.
i wrote this:
RETRY: --lebel
BEGIN TRANSACTION
BEGIN TRY
UPDATE country SET adress_country = 'pakistan' WHERE adress_id =2
WAITFOR DELAY '00:00:05' -- Wait for 5 ms
UPDATE persons SET prs_first_name ='ram' WHERE prs_id =2
COMMIT TRANSACTION
END TRY
BEGIN CATCH
PRINT 'Rollback Transaction'
ROLLBACK TRANSACTION
IF ERROR_NUMBER() = 1205 -- Deadlock Error Number
BEGIN
WAITFOR DELAY '00:00:00.05' -- Wait for 5 ms
GOTO RETRY -- Go to Label RETRY
END
END CATCH
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply