Hi all. Hoping someone can help explain this...
I have a Header table that is part of a Header/Detail set. The Header table has an AFTER INSERT trigger on it. When a new record is inserted into Header, the trigger fires and checks if the record type = XYZ, if it does, it calls a stored procedure which does the following:
- Insert combined data from the Header and Detail records into a History table
- Delete the original data from the header table
- Delete the original data from the detail table
I've found that if I rapidly insert records into the Header/Detail tables, I sometimes hit a deadlock. This is not good, because it is realistic that a bunch of these inserts may be hitting the table at once, and they need to complete.
I used Profiler to get the deadlock graph (picture attached), and it seems that the deadlocked resource is the clustered...