Re: C# SqlConnection Nested Stored Proc Deadlock

2018-01-31 Thread djones147
Hi Don't mix c# transactions and sql transactions. You will certainly have dead locks if you do. Pick one and stick with it. Check that you are not trying to read the same line that the inner stored procedure is trying to modify. Or the inverse. Then check for triggers and see what they are doin

RE: C# SqlConnection Nested Stored Proc Deadlock

2018-01-31 Thread Greg Low
Problem is that when the deadlock occurs and control is transferred to the catch block, the transaction becomes a zombie (referred to as doomed). You have to roll it back there. Once you do that, your transaction is gone. Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61

Re: C# SqlConnection Nested Stored Proc Deadlock

2018-01-31 Thread David Burstin
Thanks Preet and Greg. Unfortunately I am working with legacy code so can only make minor changes. I have some more questions :) The article referenced in Preet's answer has a while loop to retry three times. The transaction is wholly contained within that loop: Structure without the noise: WHI

RE: C# SqlConnection Nested Stored Proc Deadlock

2018-01-31 Thread Greg Low
Sorry, error 3960, not 3760 Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile│ +61 3 8676 4913 fax SQL Down Under | Web: www.sqldownunder.com |http://greglow.me *From:* Greg Low [mailto:g...@greglow.com] *Sent:* Thursday, 1 February 2018 12:40 PM *To:

RE: C# SqlConnection Nested Stored Proc Deadlock

2018-01-31 Thread Greg Low
Hi Dave, Deadlocks are batch terminating errors and unwind your whole transaction stack, unrelated to inner or outer, unless you add explicit try/catch logic as Preet mentioned. Generally, I prefer to catch them in client code rather than in T-SQL, as there are other types of errors that shou

Re: C# SqlConnection Nested Stored Proc Deadlock

2018-01-31 Thread Preet Sangha
Can you use a try catch in the outewr proc and get the error number such as in this page? https://technet.microsoft.com/en-us/library/aa175791(v=sql.80).aspx ( *SQL Essentials: Using TRY/CATCH to Resolve Deadlocks in SQL Server 2005)* regards, Preet, in Auckland NZ On 1 February 2018 at 14:42,

C# SqlConnection Nested Stored Proc Deadlock

2018-01-31 Thread David Burstin
Hi folks, Hope everyone is having a great day and enjoyed the super blue blood moon last night. Quick question: Given a stored procedure "OuterProc" that calls another stored procedure internally "InnerProc" When I call "OuterProc" from C# using a connection with a started transaction, and "Inne