Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restoring a year end backup to test company

Status
Not open for further replies.

swabunn

Technical User
Jan 25, 2006
175
CA
I have taken back up through file -> backup in Great Plains at Year end closing. Everything is fine in live company. For auditors I want to restore same backup to test company but when I go to restore the backup through File - Restore from Great plains. I am getting error saying : "The backup file you selected refers to a database other than the one you are trying to restore"

please help?

-swabunn
 
It sounds like it is trying to restore over the LIVE database. You need to create a TEST company using GP Utilities and then have your SQL admin restore the backup over the TEST database.

This is if your using SQL Server.

BobSchleicher
 
I didn't mention it before I have already created test compnay through utilities. The above error I am getting in the test company. Using SQL server server you mean through all tasks -> Restore in SQL SERVER and assigning backup file to it

-swabunn
 
Using all task is the correct way. You will have:

Force restore over existing database &
Change the paths to match the actual path of the TEST db.

After you restore the backup to the TEST db you will have to run this script to update the TEST company for use.
Code:
/******************************************************************************/
/*	Description:	*/
/*	Updates any table that contains a company ID or database name value	*/
/*	with the proper values as they are stored in the DYNAMICS.dbo.SY01500 table	*/
/*	*/
/******************************************************************************/

if not exists(select 1 from tempdb.dbo.sysobjects where name = '##updatedTables')
	 create table [##updatedTables] ([tableName] char(100)) 
truncate table ##updatedTables 
declare @cStatement varchar(255)
declare G_cursor CURSOR for 
select 
case
when UPPER(a.COLUMN_NAME) in ('COMPANYID','CMPANYID') 
	 then 'update '+a.TABLE_NAME+' set '+a.COLUMN_NAME+' = '+ cast(b.CMPANYID as char(3))
else 
	 'update '+a.TABLE_NAME+' set '+a.COLUMN_NAME+' = '''+ db_name()+''''
end
from INFORMATION_SCHEMA.COLUMNS a, DYNAMICS.dbo.SY01500 b
where 
	 UPPER(a.COLUMN_NAME) in ('COMPANYID','CMPANYID','INTERID','DB_NAME','DBNAME')
	 and b.INTERID = db_name() 
set nocount on
OPEN G_cursor
FETCH NEXT FROM G_cursor INTO @cStatement 
WHILE (@@FETCH_STATUS <> -1)
begin
	 	insert ##updatedTables select 
substring(@cStatement,8,patindex('%set%',@cStatement)-9)
	 	Exec (@cStatement)
	 FETCH NEXT FROM G_cursor INTO @cStatement 
end
DEALLOCATE G_cursor 
select [tableName] as 'Tables that were Updated' from ##updatedTables

BobSchleicher
 
Forgot to add. Run that script against the TEST company in Query Analyzer.

BobSchleicher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top