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

Опубликовано: 02 Апрель 2023
на канале: Right to Learn @BK
8k
169

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


How SQL server choses a deadlock victim




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


Microsoft technet on System health extended event


Analyze & prevent deadlocks
a.
b.


Смотрите видео How to Capture deadlock in SQL server | Trace deadlock | SQL interview Q&A | Ms SQL онлайн без регистрации, длительностью 23 минут 45 секунд в хорошем hd качестве. Это видео добавил пользователь Right to Learn @BK 02 Апрель 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 8 тысяч раз и оно понравилось 169 людям.