From a .NET 3.5 / C# app, I would like to catch SqlException
but only if it is caused by deadlocks on a SQL Server 2008 instance.
Typical error message is Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
Yet, it does not seem to be a documented error code for this exception.
Filtering exception against the presence of the deadlock keyword in their message seems a very ugly way to achieve this behavior. Does someone know the right way of doing this?
select * from master.dbo.sysmessages where error=1205
– Mangonel