HOW TO: Fix an SQL Server Deadlock?

Published on
3,674 Points
Last Modified:
Avis Moonsamy
Technical Expert and Passionate Nature Photographer
During the weekend, I was asked to investigate into a deadlock in SQL Server 2014. SQL being something I don’t really fancy myself being an expert at, I had to do some refreshing. This article is a collection of my notes.

What is a deadlock?

Basically, it is a  conflict in which one process is waiting for another to release a resource. This is also known as a block. Although in SQL Server a blocked process usually resolves itself when the first process releases the resource but there are times when a process holds a transaction lock and doesn’t release it.

This can be a serious condition, not just for SQL Server as processes become suspended, but for the applications which rely on SQL Server as well.

How to Fix it?

To fix this issue, we will use the Activity Monitor to identify the blocking process and then if possible kill it.

Activity Monitor is a tool in SQL Server Management Studio that gives you a view of current connections, processes, and locks held on SQL Server resources.

To open Activity Monitor in SQL Server Management Studio, right-click the SQL Server instance name in Object Explorer and then select Activity Monitor.

To find a blocked process with Activity Monitor, expand Processes in Activity Monitor to view more details about the processes.

Next step is to identify the process that is waiting. To do this, click on the Blocked By tab. This will sort by the column and show you all the blocked processes.

To stop the blocking process, right-click it and choose Kill Process.

If the blocking process is not eliminated by using the Kill Process, your last resort will be to restart the server. A restart of the SQL Server will clear all blocking processes.

Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free