SQL Server handles deadlocks by automatically choosing one of the sessions as a deadlock victim and aborting the transaction. In order to avoid unnecessary deadlocks, SQL Server implements a deadlock detection and resolution process.
For example, consider two sessions, A and B, that are attempting to update the same row in a table. Session A has acquired a shared lock on the row, while Session B has acquired an exclusive lock on the same row. When Session A attempts to acquire an exclusive lock on the same row, a deadlock is detected. SQL Server then chooses one of the sessions as the deadlock victim and aborts the transaction. In this case, Session B is chosen as the deadlock victim and its transaction is aborted.