Link to home
Start Free TrialLog in
Avatar of sellcenter
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.


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
;

Open in new window

Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Have you considered refreshing?
Perhaps I should have been clearer:
1. Click on the Databases object.
2, Press F5
ASKER CERTIFIED SOLUTION
Avatar of sellcenter
sellcenter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
With all due respect, that makes no sense whatsoever.  But whatever works for you.