Here I am doing a database recovery from production to development:
NOTE. I do this through the work of SSAS to release a production database daily:
Step1: deleting the backup of the previous day in development:
declare @sql varchar(1024); set @sql = 'DEL C:\ProdAEandAEXdataBACKUP\AE11.bak' exec master..xp_cmdshell @sql
Step 2. Copy the production database to the development:
declare @cmdstring varchar(1000) set @cmdstring = 'copy \\Share\SQLDBBackup\AE11.bak C:\ProdAEandAEXdataBACKUP' exec master..xp_cmdshell @cmdstring
Step 3: Repair by running the .sql script
SQLCMD -E -S dev-erpdata1 -b -i "C:\ProdAEandAEXdataBACKUP\AE11_Restore.sql"
The code that is in the AE11_Restore.sql file:
RESTORE DATABASE AE11 FROM DISK = N'C:\ProdAEandAEXdataBACKUP\AE11.bak' WITH MOVE 'AE11' TO 'E:\SQL_DATA\AE11.mdf', MOVE 'AE11_log' TO 'D:\SQL_LOGS\AE11.ldf', RECOVERY;
NonProgrammer Oct 19 '17 at 17:40 2017-10-19 17:40
source share