Error message when you copy live company to test company

If you have a test company in Dynamics GP, and you take a SQL Server backup of your live Dynamics GP company and you restore that backup over the test company, you get an error message when you try to login to the test company:

"The selected company is not configured as a company of the current Microsoft Dynamics GP system database. You must resolve the database configuration to log in to the company."

You can fix this using the following SQL:

1) Run this script to determine the cmpanyid of your TEST GP company:

Select * from dynamics.dbo.sy01500

2) Run this script to update the SY00100 table in your TEST GP company:

Update test.dbo.sy00100 set cmpanyid=2

The 2 in this script should be replaced by the cmpanyid you find by running the script in step 1.

This should fix that error.