You can minimize, (though not necessarily eliminate) deadlocks by doing two things. First, make sure your transactions are as short as possible. Don't start a transaction then hold it open while you are waiting for user input, for example.
Second, insure that you always access objects in the same order. For example, If one procedure consists of:
Begin Transaction
UPDATE OrderItems ...
UPDATE Orders ...
Commit Transaction
and a second process does:
Begin Transaction
UPDATE Orders ...
UPDATE OrderItems ...
Commit Transaction
this will pretty much guarantee a deadlock eventually. If both processes obtain the locks in the same order, then the second will happily wait until the locks are released by the first's commit.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com