sellcenter
asked on
Creating A Database copy via RESTORE WITH MOVE
Hey everyone,
I'm trying to create a copy of an MSSQL database with the RESTORE WITH MOVE command. Please find below the code I am running in my futile attempts ( database names have been changed to protect the innocent ).
I expect to see a new database called NewDatabase on my server containing all data from OldDatabase. Instead, I get:
Changed database context to 'OldDatabase'.
Query OK, -1 rows affected (234 ms)
Query OK, -1 rows affected (468 ms)
Changed database context to 'master'.
Query OK, -1 rows affected (249 ms)
Query OK, -1 rows affected (249 ms)
and no new database.
I'm trying to create a copy of an MSSQL database with the RESTORE WITH MOVE command. Please find below the code I am running in my futile attempts ( database names have been changed to protect the innocent ).
I expect to see a new database called NewDatabase on my server containing all data from OldDatabase. Instead, I get:
Changed database context to 'OldDatabase'.
Query OK, -1 rows affected (234 ms)
Query OK, -1 rows affected (468 ms)
Changed database context to 'master'.
Query OK, -1 rows affected (249 ms)
Query OK, -1 rows affected (249 ms)
and no new database.
USE OldDatabase
BACKUP DATABASE OldDatabase
TO DISK = 'C:\backups\7-14.bak'
WITH NAME = 'Full Backup of OldDatabase 7-14';
GO
USE master
RESTORE DATABASE NewDatabase
FROM DISK = 'C:\backups\7-14.bak'
WITH MOVE 'OldDatabase' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\NewDatabase.mdf',
MOVE 'OldDatabase_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\NewDatabase_log.ldf',
REPLACE
GO
;
Have you considered refreshing?
Perhaps I should have been clearer:
1. Click on the Databases object.
2, Press F5
1. Click on the Databases object.
2, Press F5
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
With all due respect, that makes no sense whatsoever. But whatever works for you.