Skip to main content

How to use deadlock priority

  • Excerpt: When developing custom SQL it's important that your code does not block the main application. This article explains how you can use deadlock priority to control this.

Deadlock priority 

The deadlock priority setting will let you control how important you code is in the event of a deadlock.

 The priority is low, medium and high.

When a deadlock occurs, SQL Server will rollback the cheapest transaction. 

The DEADLOCK PRIORITY is placed right before the BEGIN TRAN clause.

SET DEADLOCK PRIORITY LOW
BEGIN TRAN
   -- Do your stuff here
COMMIT TRAN

This snippet will be rollbacked if it's involved in a deadlock.