Fix : Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
Deadlock occurs when two users have locks on separate objects and each user wants a lock on the other’s object. When this happens, SQL Server ends the deadlock by automatically choosing one and aborting the process, allowing the other process to continue. The aborted transaction is rolled back and an error message is sent to the user of the aborted process. Generally, the transaction that requires the least amount of overhead to rollback is the transaction that is aborted.
Fix/Workaround/Solution:
Deadlock priority can be set by user. In other words, user can choose which process should stop to allow other process to continue. SQL Server automatically chooses the process to terminate which is running completes the circular chain of locks. Sometime, it chooses the process which is running the for shorter period then other process.
To reduce the chance of a deadlock:
- Minimize the size of transaction and transaction times.
- Always access server objects in the same order each time in application.
- Avoid cursors, while loops, or process which requires user input while it is running.
- Reduce lock time in application.
- Use query hints to prevent locking if possible (NoLock, RowLock)
- Select deadlock victim by using SET DEADLOCK_PRIORITY.
SQL SERVER 2005 has new priority HIGH as well as numeric-priority.
SQL SERVER 2005 Syntax
SET DEADLOCK_PRIORITY { LOW | NORMAL | HIGH | <numeric-priority> | @deadlock_var | @deadlock_intvar }
<numeric-priority> ::= { -10 | -9 | -8 | … | 0 | … | 8 | 9 | 10 }
Example:
The following example sets the deadlock priority to NORMAL.
SET DEADLOCK_PRIORITY NORMAL;
GO
Reference : Pinal Dave (http://blog.SQLAuthority.com)




Got the exact error but unable to resolve as I am trying to shink the database
Hi..
I have also received the Error “Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction”
.
could you please tell me how to fix this error. I am using two diffeent VB Applications whis use same SQL Server 2000 database.
I have found the one process which became a victim. Could you please let me know where to set up the DEADLOCK_PRIORITY as i am new in SQL server 2000. I really appreciate your help.
Regards
Nitesha
Hi..
I have also received the Error “Error 1205 : Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction”
.
could you please tell me how to fix this error. I am using two diffeent VB Applications whis use same SQL Server 2000 database.
I have found the one process which became a victim. Could you please let me know where to set up the DEADLOCK_PRIORITY as i am new in SQL server 2000. I really appreciate your help.
Regards
Nitesha
Pinal, you have an awesome website! I am a novice at SQL and I have run into this issue:
System Error System Error DB: Exception encountered. Table: PATIENT/STUDY Operation: FINDFIRST Id: Error: Transaction (Process ID 62) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
State:40001,Native:1205,Origin:[Microsoft][ODBC SQL Server Driver][SQL Server]
How do I fix this, what is happening is the Dicom service which is reporting this is stopping once a day with this message and it is critical because it is a hospital and this service need to run non-stop. Could you please help?
Thank you in advance.
Can I find out which users are using which process?
Deadlock occurs when two users have locks on separate objects and each user wants a lock on the other’s object.
I have a feeling that one of the users does not need to be there. I logged on with two seperate accounts and setup replication.
The first, which I used the wrong account might be in there still.
Hi Randy!
You can use the stored procedure SP_WHO2
Regards.
MS SQL 2005 is supposed to be a multi-user database, unlike Access, so why isn’t it smart enough to queue up the requests and process them in a linear fashion if it’s otherwise going to cause a deadlock?
I’ve got a SP that takes less than 300ms to run consisting of a few selects, updates and inserts. I saw the deadlock error on 4 computers when users tried to run the same SP (with different params) within a second or two of each other. Only 1 person didn’t get an error. SQL should just queue the requests to avoid creating deadlock victims. I’m very annoyed with it, I thought it was smarter than that. It should be for what it costs. :-(
Hi , me facing the same error , We are running stored procedure one by one with out keeping a time gap, now the problem is that i have to track where in the procedure deadlock is coming .. i have to figure out that so that we can fix that part of coding ..
Its real urgent do help..
If possible send the Solution in my mail ashish_vbtecno@indiatimes.com
Hi,
I am observing this error when i do a set of action in application using SQL Server 2008 Database.
SQL Message: Transaction (Process Id ??) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
I understand what deadlock is, but I am not able to relate it to the action in Application.
If the deadlock happen when it was doing Insert into table, does that tell something about deadlock
[...] Always access tables in the same order in all stored procedure and triggers consistently. This will avoid deadlocks. (Read More Here) [...]
I’m receiving this with my accounting package, generally when posting batches. If I understand this correctly, the SQL server is telling the application that it’s not able to write its transaction at this time.
What the application SHOULD do at this point, is to pause and attempt to re-post its data to the SQL server after a short delay. Would that be correct?
Dear Friends,
I am using SQL 2000 with RAMCO ERP, HP DL360G5 Server with 8GB RAM, RAID 5, HDD 4×15000RPM & utlization 7.74GB RAM Total Database size 70GB but too much blocking happned in my server. After Restart server will functional normal for 4 to 5 hours after again reduced performance. SP4 with HOtfix all installed in server Setting
name minimum maximum config_value run_value
———————————– ———– ———– ———— ———–
affinity mask -2147483648 2147483647 0 0
allow updates 0 1 0 0
awe enabled 0 1 1 1
c2 audit mode 0 1 0 0
cost threshold for parallelism 0 32767 10 10
Cross DB Ownership Chaining 0 1 0 0
cursor threshold -1 2147483647 -1 -1
default full-text language 0 2147483647 1033 1033
default language 0 9999 0 0
fill factor (%) 0 100 51 51
index create memory (KB) 704 2147483647 0 0
lightweight pooling 0 1 0 0
locks 5000 2147483647 0 0
max degree of parallelism 0 32 4 4
max server memory (MB) 4 2147483647 7449 7449
max text repl size (B) 0 2147483647 65536 65536
max worker threads 32 32767 255 255
media retention 0 365 0 0
min memory per query (KB) 512 2147483647 6666 6666
min server memory (MB) 0 2147483647 3071 3071
nested triggers 0 1 1 1
network packet size (B) 512 32767 4096 4096
open objects 0 2147483647 0 0
priority boost 0 1 1 1
query governor cost limit 0 2147483647 0 0
query wait (s) -1 2147483647 -1 -1
recovery interval (min) 0 32767 0 0
remote access 0 1 0 0
remote login timeout (s) 0 2147483647 20 20
remote proc trans 0 1 0 0
remote query timeout (s) 0 2147483647 600 600
scan for startup procs 0 1 0 0
set working set size 0 1 1 1
show advanced options 0 1 1 1
two digit year cutoff 1753 9999 2049 2049
user connections 0 32767 0 0
user options 0 32767 0 0
Please help me how to reduce blocking.