Skip to main content

What is Deadlock? How does SQL Server detect and resolve it?

Mid MS SQL
Quick Answer A deadlock forms when transaction A holds lock 1 and wants lock 2, while transaction B holds lock 2 and wants lock 1. Neither can proceed. SQL Server's deadlock monitor runs every 5 seconds, detects the cycle, picks the cheapest victim, rolls it back, and lets the other complete. Victims get error 1205.

Answer

A deadlock occurs when sessions wait on each other indefinitely. SQL Server detects deadlocks every 5 seconds and selects a victim to kill.

Prevention includes using consistent resource order, short transactions, and proper indexes.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice