70-465 · Question #117
You use SQL Server 2014 to maintain the data used by applications at your company. You want to execute two statements. You need to guarantee that either both statements succeed, or both statements…
The correct answer is D. Option D. This question tests the use of explicit transactions in T-SQL to ensure atomicity - guaranteeing that multiple statements either all succeed or all fail together.
Question
Exhibit
Options
- AOption A
- BOption B
- COption C
- DOption D
- EOption E
How the community answered
(32 responses)- A3% (1)
- B6% (2)
- D88% (28)
- E3% (1)
Why each option
This question tests the use of explicit transactions in T-SQL to ensure atomicity - guaranteeing that multiple statements either all succeed or all fail together.
Option A likely executes the statements without any transaction control, meaning each statement commits independently and a failure of one does not roll back the other.
Option B likely uses an incomplete or incorrect transaction structure, such as missing a ROLLBACK in an error-handling path, which does not guarantee atomicity on failure.
Option C likely uses a TRY/CATCH without proper BEGIN/COMMIT/ROLLBACK transaction statements, so SQL Server cannot treat both statements as a single atomic unit.
Option D uses an explicit transaction with BEGIN TRANSACTION, a TRY/CATCH block, COMMIT TRANSACTION on success, and ROLLBACK TRANSACTION on failure. This pattern guarantees atomicity by wrapping both statements in a single logical unit of work, ensuring that if either statement fails, the CATCH block triggers a ROLLBACK and neither change is persisted to the database.
Option E likely uses SET XACT_ABORT or another partial mechanism that does not fully implement explicit transaction control with both COMMIT and ROLLBACK paths required for guaranteed atomicity.
Concept tested: T-SQL explicit transactions with TRY/CATCH atomicity
Source: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/try-catch-transact-sql
Topics
Community Discussion
No community discussion yet for this question.
