Creating A Database copy via RESTORE WITH MOVE

Posted on 2009-07-14
Medium Priority
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
TO DISK = 'C:\backups\7-14.bak'
   WITH NAME = 'Full Backup of OldDatabase 7-14';
USE master
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',

Open in new window

Question by:sellcenter
  • 3
LVL 75

Expert Comment

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

Expert Comment

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

Accepted Solution

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.
LVL 75

Expert Comment

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

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

621 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