Hi @Santosh Jodangi ,
“Transaction was deadlocked” error occurs when two or more sessions are waiting to get a lock on a resource which has already locked by another session in the same blocking chain. As a result, none of the sessions can be completed and SQL Server has to intervene to solve this problem. It gets rid of the deadlock by automatically choosing one of the sessions as a victim and kills it allowing the other session to continue. The killed session is rolled back.
You can check the system_health session for deadlocks, create an extended event session to capture the deadlocks. Then analyze the deadlock reports and graphs to figure out the problem. Please refer to the blog How to resolve deadlocks in SQL Server to get detail steps.
For the question about avoiding the deadlock, suggest you read How to Avoid Deadlocks in SQL Server part in this blog, hope this could help you.
If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.