Question : How 2 resolve deadlock in SQL Server

Hi All,
How 2 identify deadlock in SQL Server?
How 2 resolve deadlock in SQL Server?
How 2 find which process has to be stopped in case if 2 process creating a deadlock?

Answer : How 2 resolve deadlock in SQL Server

How 2 identify deadlock in SQL Server?
SQL Server will do that for you. ;-)

How 2 resolve deadlock in SQL Server?
SQL Server will do that for you, too, by aborting one of the SQL statements. ;-)


How 2 find which process has to be stopped in case if 2 process creating a deadlock?
Don't worry about it, SQL Server will do that for you, too. ;-)

Essentially, the only way you will get deadlocks is if two (or more) statemenst are both trying to access the same data and one of tham has locked it.  In that case, the one that has not locked the data will be cancelled.  Now, that can be a situation where a row, data-page, table, index row, or index page is locked, depending on the default or "hinted" lockingof one or both statements.

Whenever SQL Server (or, for that matter, most other more robust database engines) determines that tehre is a locking situation, it may wait a little bit at first but, if the locking is persistent, it will cancel whichever query is most easily cancelled (e.g. a SELECT vs an UPDATE).  (You can get an idea as to which queries are having problems if you use a tool like PerfMon or Confio's Ignite.)

Random Solutions  
 
programming4us programming4us