Try to keep transactions short; this will avoid holding locks in a transaction for a long period of time.Access objects in a similar logical manner in multiple transactions.Create a covering index to reduce the possibility of a deadlock.
How can database prevent deadlocks?
- Ensure the database design is properly normalized.
- Develop applications to access server objects in the same order each time.
- Do not allow any user input during transactions.
- Avoid cursors.
- Keep transactions as short as possible.
How can we avoid deadlock while updating SQL Server?
Update lock (U) is used to avoid deadlocks. Unlike the Exclusive lock, the Update lock places a Shared lock on a resource that already has another shared lock on it.