In the code below when I am inserting data in a table then what is the purpose of rollback I should not insert it if I want to rollback so what is the appropriate way to use rollback?
BEGIN TRANSACTION Insert into dimCustomr Values('xyz',345435353) ROLLBACK;
Using the rollback method, you can close the transaction, reverting all associated changes made to the database. Eg:

Above diagram illustrate the three query at a time.Tansaction of query1 & query2 were successful but query3 got error. And when query3 got error all transaction will revert.
A Rollback is executed if a transaction aborts. It makes the whole Transaction undone. A transaction could be aborted through several errors that might occour when running the transaction or if you does an unplaned power off of your system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With