Monday, July 2, 2018

LS NAV - Copy Live to Test

BACKUP DATABASE [NAV] TO  DISK = N'S:\Backup\NAV_temp.bak' WITH NOFORMAT, INIT,  NAME = N'NAV-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO
USE [master]
ALTER DATABASE [TEST] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE [TEST] FROM  DISK = N'S:\Backup\NAV_temp.bak' WITH  FILE = 1,  MOVE N'w1-ls-nav-11-0-release_Data' TO N'S:\SQLSVR2016\MSSQL13.MSSQLSERVER\MSSQL\DATA\TEST_Data_0.mdf',  MOVE N'w1-ls-nav-11-0-release_1_Data' TO N'S:\SQLSVR2016\MSSQL13.MSSQLSERVER\MSSQL\DATA\TEST_1_Data_0.ndf',  MOVE N'w1-ls-nav-11-0-release_Log' TO N'S:\SQLSVR2016\MSSQL13.MSSQLSERVER\MSSQL\DATA\TEST_Log_0.ldf',  NOUNLOAD,  REPLACE,  STATS = 5
ALTER DATABASE [TEST] SET MULTI_USER

GO
  FROM
  update [TEST].[dbo].[CRONUS$Distribution Location] set [Db_ Path && Name] = 'TEST' where [Db_ Path && Name] = 'NAV'
  update [TEST].[dbo].[CRONUS$Distribution Location] set [Db_ Path && Name] = 'POSTEST' where [Db_ Path && Name] = 'NAV'
  update [TEST].[dbo].[CRONUS$Distribution Location] set [Web Server Name] = 'TEST'
  update [TEST].[dbo].[CRONUS$Distribution Location] set [Web Service URI] = ''

--Change Company Name
UPDATE [TEST].[dbo].[CRONUS$Company Information] set [Name] = 'CRONUS STAGING'
  update [TEST].[dbo].[Company] set [Display Name] = 'CRONUS STAGING' where [Name] = 'CRONUS'

No comments:

Post a Comment