Search This Blog

Wednesday, January 21, 2009

Running Deadlock trace in SQL server 2000

Turn on deadlock trace
DBCC TRACEON(1204,1222)

DBCC TRACEON (3604)
DBCC TRACEON (1204)
To turn off deadlock tracing and logging:
DBCC TRACEOFF (3604, 1204)

This will enable deadlock tracing for all existing connections and new. You can check out KB832524 for more details. Trace flag 1204 reports deadlock information formatted by each node involved in the deadlock. Trace flag 1222 formats deadlock information, first by processes and then by resources.

Use SQL Profiler to trace deadlock events and get the resource ID of the table or index under contention. The steps to do this are:
  1. Start SQL profiler
  2. On the Trace Properties dialog box, on the General tab, check Save to file and specify a path to save the trace
  3. Click the Events tab, only add Locks\Lock:deadlock and Locks\Lock:deadlock chain
  4. Click the Data columns tab, add DatabaseID, IndexID, ObjectID
This trace will record all deadlocks on this SQL Server instance, along with the ID of the source table of contention

No comments: