SQL Handle to SQL Text

SQL Handle to SQL Text with Statement Start and Statement End: DECLARE @sql_handle VARBINARY(64) , @stmtstart INT , @stmtend INT SELECT @stmtstart = 3268 , @stmtend = 5102 , @sql_handle = 0x03000800d8c3dd70e2f83f01e2a300000100000000000000 SELECT SUBSTRING(qt.text, s.statement_start_offset / 2, ( CASE WHEN s.statement_end_offset = -1 THEN LEN(CONVERT(NVARCHAR(MAX), …

Deadlocks : Count , Analysis and Event Notification

SQL Server : Number of Deadlocks since Last SQL Server Restart SELECT sqlserver_start_time AS ServerRestartTime FROM sys.dm_os_sys_info SELECT * FROM sys.dm_os_performance_counters WHERE counter_name = ‘Number of Deadlocks/sec’ AND instance_name = ‘_Total’ — Trace Flags to Capture Deadlock Events DBCC TRACESTATUS(1222) DBCC TRACEON(1222,-1) DBCC TRACEOFF(1222,-1) Extended …

SQL Server – Read Errorlog

Enable Audit log to capture successful and failed Logins — To Enable Failed and Successful Logins — Need to Restart the Server for this to effect EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’AuditLevel’, REG_DWORD, 3; GO — Query for Successful Logins EXEC sys.sp_readerrorlog @p1 = 0, — …

Index Pointers

Indexes  – Pointers to Consider Max index size – 16 columns or 900 bytes whichever comes first Page Size – 8 KB – 8192 Bytes  Storage Available = 8192 Bytes – 96 Bytes for non-data storage = 8096 bytes / Page for Data. Useful DMV: …