title: SQL Azure - Transaction (Process ID 160) was deadlocked on lock resources with another process and has been chosen as the deadlock victim
body: <p>We are experiencing the mentioned dead lock exception while doing CRUD on two SQL Server tables from parallel threads by calling Stored Procedures, here is the detailed scenario:</p>
  
  <p>We have a desktop application where we are spinning up a code block in 100 - 150 parallel threads, the code block does insertion in TableA using <a href="https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy(v=vs.110).aspx" rel="nofollow noreferrer">SQL Bulk Copy</a> and makes calls to three Stored Procedures, The stored procedures do insertion, updation and deletion in TableB based on some selection from TableA.</p>
  
  <p>Soon as the application starts execution of the threads, SQL Server starts throwing the mentioned dead lock exception for a certain number of threads while some of the threads do run fine.</p>
  
  <p>Exception Message:
  Transaction (Process ID 160) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.</p>
  
  <p>Any help in this regard is appreciated in advance.</p>
  
  <p>Thanks.</p>