How to avoid sql deadlock?

I am using MS-SQL 2008 and for coding using C # in a web project.

I am currently stuck in sql deadlock.

I have 2 transactions, one of two is a long transaction.

When both transactions are performed simultaneously, a deadlock occurs and the short transaction will be automatically deleted.

My current solution, I caught the deadlock exception and redid the short transaction, it works well, just take the time.

But, I wonder if there is any solution to avoid a deadlock due to the root cause?

+2
c # sql sql-server-2008
source share
1 answer

No, you cannot completely eliminate the locks, just reduce them.

+6
source share

All Articles