Scenario: While executing a complex SQL transaction, an error occurs, and you need to roll back the changes made so far. What steps should you follow to perform a proper rollback?

  • Delete the affected rows manually to revert the changes.
  • Execute a new COMMIT TRANSACTION statement to finalize the changes.
  • Restart the SQL Server service to reset the transaction log.
  • Use the ROLLBACK TRANSACTION statement to undo the changes.
Manually deleting affected rows is not a recommended approach as it might lead to data inconsistency. Restarting the SQL Server service is a drastic measure and may disrupt other ongoing operations. Executing a new COMMIT TRANSACTION statement would finalize the changes, which is contrary to the goal of rolling back. The correct step is to use the ROLLBACK TRANSACTION statement to undo the changes made so far and maintain data integrity.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *