A developer needs to ensure that a series of data modifications within a stored procedure are treated as a single, atomic unit. If an error occurs at any point, all prior modifications within the procedure should be undone. Which T-SQL construct is most appropriate for handling this requirement?
-
A
A cursor to iterate through the statements.
-
B
A TRY...CATCH block combined with a transaction.
-
C
A temporary table to log changes before applying them.
-
D
An AFTER trigger on the target table.