Have you ever had to update a table in GP and made a mistake. No! Never right? Then had to restore the database to bring it back before you ran the statement. Dang!! I forgot to make a backup! How many times have you had to restore before getting it right?
Well there is in SQL the Rollback and Commit Statements to help rollback your changes in case of the OOPS!! or in case you forgot to back-up the database. Then you Commit in case you are perfect. For a few seconds more, you can save a time and heartache.
Example :
– How to not commit changes in your database until you are sure it works and can roll back the changes without doing a restore of the database.
–Below is an example of an Update Set command that can be rolled back in case of OOPS!!
– Uses a Specific Database
– Step One
Select * RM00101 where ChekBKID=’Main’
–check the number of rows for transactions
– Step Two
Begin Tran
Update RM00101 Set ChekBkId=’New’ where ChekBkId=’Main’
– check the number of rows for transactions to make sure it matches your first select statement
– you can run the select statement again by just highlighting it and make sure it is ’0′ rows and no data.
– Step Three or Four
Commit
–run this if everything works great
Rollback
– run this if you did something wrong OOPS
The post Rollback your SQL script w/o restoring the database appeared first on Rose Business Solutions Dynamics GP.