Solved

Creating A Database copy via RESTORE WITH MOVE

Posted on 2009-07-14
4
514 Views
Last Modified: 2012-05-07
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

0
Comment
Question by:sellcenter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24851938
Have you considered refreshing?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24851947
Perhaps I should have been clearer:
1. Click on the Databases object.
2, Press F5
0
 

Accepted Solution

by:
sellcenter earned 0 total points
ID: 24864559
I've found the solution.  I need to add a "GO" on line 2 in the above code.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24865435
With all due respect, that makes no sense whatsoever.  But whatever works for you.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question