Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to avoid deadlocks?

Author  Topic 

Mits
Starting Member

48 Posts

Posted - 2003-09-30 : 04:08:22
hi all,
i am using SQL 2000 and VB 6.0.
i am randomly experiencing deadlock in my application.How can i completely avoid deadlock,if not avoid then handle it effeciently in background.

Thanks

Mits

dsdeming

479 Posts

Posted - 2003-09-30 : 08:25:41
Have a look at Minimizing Deadlocks in BOL. The most common cause of deadlocks, in my experience, is when two process perform DML against the same two tables but in different order ( process 1 updates table a and then table b; process 2 updates table b and then table a ). Tracking them down can be a real pain. They're not random, but they are almost always intermittent.

Dennis
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-09-30 : 09:47:15
>> How can i completely avoid deadlock
In a multi-user system you never can without blocking processes (even then I suspect you can get deadlocks with system processes).
You can minimise them by thinking about how the tables will be accessed when you design the system.
The main rule is to avoid aggregate queries on tables that are updated.

Your client should handle a deadlock return code and retry the operation if allowable.
If you identify the processes that are causing the deadlocks you can make sure that they don't run together by locking a resource whike they perform the processing. It will slow things down a bit but should reduce the deadlocks.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -