views:

162

answers:

2
  1. What are the possible situations which make deadlock happen on SQL server?
  2. How to solve with that situation?
A: 

A really simple explanation when a Dead Lock happen (when ive got it wrong, sorry im no DBA :) ):

Both Transaction run parallel

Transaction 1

Select * From Table1 Select * From Table2

Transaction 2

Select * From Table2 Select * From Table1

T1 waits for Table2 and T2 waits for Table1

One optimization is to do the SQL Statements in the same Order. MSSQL Sever has an Option with nolock, but there you have the Dange of inconsitent data.

Richard