70-465 · Question #52
You need to recommend a solution that addresses the concurrency requirement. What should you recommend?
The correct answer is B. Modify the stored procedures to update tables in the same order for all of the stored. Deadlocks in SQL Server commonly occur when stored procedures access tables in inconsistent orders, causing circular wait conditions. Ensuring all procedures update tables in the same order eliminates this circular dependency.
Question
Options
- ACall the stored procedures in a Distributed Transaction Coordinator (DTC) transaction.
- BModify the stored procedures to update tables in the same order for all of the stored
- CMake calls to Sales.Proc1 and Sales.Proc2 synchronously.
- DBreak each stored procedure into two separate procedures, one that changes
How the community answered
(39 responses)- A3% (1)
- B79% (31)
- C5% (2)
- D13% (5)
Why each option
Deadlocks in SQL Server commonly occur when stored procedures access tables in inconsistent orders, causing circular wait conditions. Ensuring all procedures update tables in the same order eliminates this circular dependency.
Using a DTC transaction adds distributed transaction overhead and still does not prevent deadlocks if the underlying table access order remains inconsistent across procedures.
When multiple stored procedures acquire locks on the same tables but in different orders, they can create circular wait chains that result in deadlocks. By standardizing the table update order across all stored procedures, you ensure that locks are always requested in the same sequence, preventing circular dependencies and resolving the concurrency/deadlock issue without requiring distributed transactions or architectural changes.
Making calls to Sales.Proc1 and Sales.Proc2 synchronously serializes application-level execution but does not address deadlocks that occur within the database engine due to inconsistent lock ordering across concurrent sessions.
Breaking each stored procedure into two separate procedures does not inherently resolve deadlocks unless the resulting procedures also update tables in a consistent order, making this an incomplete and unnecessarily complex solution.
Concept tested: Deadlock prevention via consistent table update ordering
Source: https://learn.microsoft.com/en-us/sql/relational-databases/sql-server-deadlocks-guide
Topics
Community Discussion
No community discussion yet for this question.