How to Capture deadlock in SQL server | Trace deadlock | SQL interview Q&A | Ms SQL

Описание к видео How to Capture deadlock in SQL server | Trace deadlock | SQL interview Q&A | Ms SQL

This video focus on how to capture a deadlock in SQL server. If you are a beginner then this video is for you. Please refer below video reference links that are discussed in this video.

What is a deadlock and how it occurs
   • What is a Deadlock in SQL Server | Ho...  

How SQL server choses a deadlock victim
   • How SQL server choose a Deadlock Vict...  



T-SQL script to find How many deadlock occured since server startup
SELECT 'Deadlocks Occurrence',
CONVERT(BIGINT,((1.0 * v.cntr_value /
NULLIF(datediff(DD,w.create_date,CURRENT_TIMESTAMP),0)))) as
AvgPerDay,
CAST(v.cntr_value AS NVARCHAR(100)) + ' deadlocks recorded since startup.' AS Details,
w.create_date as StartupDateAndTime
FROM sys.dm_os_performance_counters v
INNER JOIN sys.databases w ON w.name = 'tempdb'
WHERE RTRIM(v.counter_name) = 'Number of Deadlocks/sec'
AND RTRIM(v.instance_name) = '_Total'

Turn on Trace flags
DBCC TRACEON (1204, -1)
DBCC TRACEON (1222, -1)


Analyzing Deadlocks with SQL Server Profiler
https://learn.microsoft.com/en-us/pre...)

Microsoft technet on System health extended event
https://social.technet.microsoft.com/...

Analyze & prevent deadlocks
a. https://learn.microsoft.com/en-us/sql...
b. https://learn.microsoft.com/en-us/azu...

Комментарии

Информация по комментариям в разработке