SQL 2005 - How to trap or catch deadlocks when they happen regardless of which sql statement caused them?

I suspect I am having issues with deadlocks.  One of our .NET applications gets a timeout error after attempting, and then re-attempting an inline update statement.  Ive seen this sort of problem before and it was another process that was doing a long running job against one of the same tables.

Now the problem is I cant tell when this will occur again, nor do I know what other process might be doing this.

What I do know is the specific table that our application is trying to do the update against.

What is a good way to find out more details when this happens? I need enough info to trace it back to the application that is doing it.


July 2nd, 2013 8:33am

There are some way to capture dead locks in sql server.

1. Extended Events

2. Sql Trace & Sql Profilers.

I suggest reading below urls help you.

http://blogs.msdn.com/b/sqlserverfaq/archive/2013/04/27/an-in-depth-look-at-sql-server-memory-part-2.aspx

http://msdn.microsoft.com/en-us/library/ms190465.aspx

http://rical.blogspot.com/2013/03/capturing-deadlock-in-sql-server-with-system-health-and-event-notification.html

http://www.mssqltips.com/sqlservertutorial/252/tracing-a-sql-server-deadlock/

Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2013 8:40am

Yes, thank you!  I was just searching Bing and ran across some discussions of using profiler.  Thats what im going to try.

There is quite a bit you can do with profiler.

July 2nd, 2013 8:44am

You can try TraceOn or the -T command-line startup option.  Flag 1222 provides information about deadlocks.

DBCC TraceOn(1222, -1)
Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2013 9:03am

Well dang it, I had a trace going that included deadlock events, and when I got this error again, the trace didnt catch anything.  So maybe its not a deadlock issue afterall?

Time to modify the error handling to get more details.

July 2nd, 2013 12:08pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics