How can I avoid deadlocks?

Basically, the application must ensure that it locks the database tables as little as possible, and only in a standard sequence, so as to avoid deadlocks. Note 565710 describes some known cases and offers corrections. In rare cases, deadlocks are caused not only by the application; the architectural details of the SQL server are also significant. Such deadlocks occur only when you process particularly extensive SQL queries, perform large-scale parallel processing (also parallel execution plans), or implement (parallel) mass changes. In the error log entry for the deadlock, you usually recognize this situation by the fact that the resource on which the deadlock occurs is not a table row (as is usually the case), but instead an internal SQL Server resource that is required while processing the SQL query.