What the script does ------------------------- This script helps to identify the deadlock from the sql error log Things to Note ------------------- The script will only capture the deadlock in the most recent error log, The first parameter in the "Sp_ReadErrorlog" needs to change in case the older deadlock are require. Pre Requirements ------------------------ 1204 or 1222 error flag needs to be enabled CREATE TABLE #Temp_All_LgData (ID int IDENTITY (1, 1), LogDate datetime, ProcessInfo nvarchar(50), LogText nvarchar(max)) CREATE TABLE #Temp_Results (ID int IDENTITY (1,1), LogDate datetime, ProcessInfo nvarchar(50), LogText nvarchar(max)) CREATE TABLE #Temp_DedLockID (ID int, processinfo nvarchar(50)) -- all the data in the error log will be recorded here INSERT INTO #Temp_All_LgData EXEC sp_readerrorlog 0,1 -- only the records with "Deadlock-list" in the text will be recorded INSERT INTO #Temp_DedLockID SELECT ID, processinfo FROM #Temp_All_Lg...
This blog is to, share the encounters and learning’s of Sql Server