The Easy Way to Refresh Your Dynamics GP Test Company – Part 2

By Tim Gable | October 9, 2019

In our last session on the Easy Way to Refresh Your Dynamics GP Test Company - Part 1, we created a backup job to refresh our test company.  In this session, we will work on the restore portion of the SQL job we are creating.

1) Go to the server where SQL Server is installed and your Dynamics GP databases are located.

2) Open SQL server management studio and login as SA or a system administrator of SQL Server.

3) Right-click on the test database you will be restoring the copy of your live company database to.

4) Select tasks>>Restore>Database…

5) In the Restore Database window select

  • Device
  • Now click the ellipse and then the Add button to navigate to the backup you created in the previous session.
  • Then click OK twice to accept the backup you selected.

6) Once you have selected the backup file it is important to be sure the Destination Database remains the database you wish to restore to. Some versions of SSMS will change this destination back to the live database which could cause data corruption when the job is run.

  • Now select the Files option in the left pane and expand the “Restore As” file path. Make sure the database file names are of the GP TEST company database you wish to restore to and NOT the live db file name.  You may have to check the box  “Relocate all files to folder” if the files are not in the default location or you may have to manually path to the correct location if necessary.

  • Now select the Options folder on the right pane.
    1. Check the Overwrite the existing database (With Replace) checkbox
    2. Mark the Close existing connections to the destination database. (may not be available in older versions of SSMS)

7) Review all settings noted above one more time and then select the Script drop-down and then “New Query Editor Window” option. Once “New Query Editor Window” option is selected, you can click cancel on the Restore Database window.

8) You should now go to the new query editor window and select all the SQL code that was created. Then right-click the selected code and then click copy.

9) Open the SQL Agent job you created from our last session.

  • Go to SQL Server Agent expand jobs and Select the job. In this case, I called it “Back Up Database – Two and restore to Test”. Double click the job to open it or right-click and select properties
  • In the left pane select Steps and then at the bottom of the window select new.
  • When the New Job Step window opens select General on the left and then name the job on the right pane. In this case, I called it Restore Live Database on to Test Database.
  • Under “Database” select the destination database. (this would only have an effect if the job step did not name the working database)
  • Right-click in the command window and paste the SQL code you previously copied.

  • Now select “Advanced” from the left window and “On success action” from the right pane.
  • Select “Go To Next Step” and click ok.
  • Click OK one more time to close job and ignore any warning messages.

In our next session, we will finish the SQL job by adding the script to activate the new test company. Check out our previous blog on building the job.


Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!