Skip to main content

Posts

Showing posts from June, 2012

Capture the Deadlock-List from the Errorlog

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...

The Different options of checking the Statistics

DBCC SHOW_STATISTICS ( 'Person_Address' , 'PK_Person_Address_rowguid' ); -    Only the header dertails will be shown DBCC SHOW_STATISTICS ( 'Person_Address' , 'PK_Person_Address_rowguid' ) WITH STAT_HEADER -- Only the histogram details will be shown DBCC SHOW_STATISTICS ( 'Person_Address' , 'PK_Person_Address_rowguid' ) WITH HISTOGRAM