I have a stored proc that inserts a row. If a field is not null, it performs the insertion and it increases the value of that field by 1 , else it inserts a record with that field set to 1.
However this is run as part of a batch job, it ends up in a deadlock sometimes and when it is re-run, I get an error saying that I cannot perform the insertion as a duplicate entry exists. So, I decided to encapsulate the 2 inserts (1 if the field is null and the other insert for the case when the field is not null) inside a transaction as follows.
However, I would like to test it now to see if it causes the deadlock still or if I still get the duplicate row error, but I dont know how to simulate it.
Any help will greatly be appreciated.