Solved

DB restore

Posted on 2006-11-16
13
508 Views
Last Modified: 2012-06-27
Not want to affect the online DB, can I restore the backup DB to another folder with another name by sql.
0
Comment
Question by:turbot_yu
[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
  • 7
  • 5
13 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17954914
restore database 'NewName'
FROM disk = 'CompletePath'
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17954924
Sorry

    restore database 'NewName'
FROM disk = 'CompletePath'
WITH MOVE 'urMdfPhysicalName' TO 'c:\test\MdfFile.mdf',
   MOVE 'urLogPhysicalName' TO 'c:\test\LogFile.ldf'
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17954928
In order to get the Physical name use

RESTORE FILELIST ONLY
WITH DISK ='Complete path of ur backUp file '
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Sirees
ID: 17955588
Check "Restoring a Complete Backup to a New Database on the Same Server" and "Restoring a Complete Backup to a New Server"
from this link

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlbackuprest.mspx#EMMAC
0
 

Author Comment

by:turbot_yu
ID: 17963059
I tried to

RESTORE DATABASE ming_new_by_sql FROM DISK = 'd:\db\BACKUP\mings.Bak'
WITH MOVE 'ming' TO 'd:\db\ming_bk.mdf'
MOVE 'ming_log' TO 'd:\dbming_bk_log.ldf'

but get error with

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'MOVE'.

Any suggestion?
0
 

Author Comment

by:turbot_yu
ID: 17963081
I tried

RESTORE FILELIST ONLY
WITH DISK ='d:\db\BACKUP\ming.Bak'

but error

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'FILELIST'.
Msg 319, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.

0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17963094
I am sorry , try with  'FILELISTONLY' (no space b/e those 2 words )


Here is an Example from Books online

This example creates a new database called MyNwind2_Test. MyNwind2_Test is a copy of the existing MyNwind2 database that comprises two files: MyNwind2_data and MyNwind2_log. Because the MyNwind2 database already exists, the files in the backup need to be moved during the restore operation. The RESTORE FILELISTONLY statement is used to determine the number and names of the files in the database being restored.

USE master
GO
-- First determine the number and names of the files in the backup.
-- MyNwind_2 is the name of the backup device.
RESTORE FILELISTONLY
   FROM MyNwind_2
-- Restore the files for MyNwind2_Test.
RESTORE DATABASE MyNwind2_Test
   FROM MyNwind_2
   WITH RECOVERY,
   MOVE 'MyNwind2_data' TO 'D:\MyData\MyNwind2_Test_data.mdf',
   MOVE 'MyNwind2_log' TO 'D:\MyData\MyNwind2_Test_log.ldf'
GO


0
 

Author Comment

by:turbot_yu
ID: 17963217
Now I use the command below to backup, how to restore from ming.bak

USE ming
GO
BACKUP DATABASE ming
TO DISK = 'd:\db\BACKUP\ming.Bak'
GO


Online DB file: d:\db\ming.mdf and  d:\db\ming.ldf
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17963231
Step1.  find the physical filenames

RESTORE FILELISTONLY
FROM  DISK = 'd:\db\BACKUP\ming.Bak'


Say it gave me the files as  Ming_Data  and Ming_log.

Step2 : restore the database as a new name

RESTORE DATABASE Ming_Test
   FROM MyNwind_2
   WITH RECOVERY,
   MOVE 'Ming_data' TO 'D:\MyData\Ming_Test_data.mdf',
   MOVE 'Ming_log'  TO 'D:\MyData\Ming_Test_log.ldf'
GO
0
 

Author Comment

by:turbot_yu
ID: 17963305
I tried

RESTORE DATABASE ming_test
   FROM ming
   WITH RECOVERY,
   MOVE 'Ming' TO 'D:\db\Ming_Test_data.mdf',
   MOVE 'Ming_log'  TO 'D:\db\Ming_Test_log.ldf'
GO


got:

Msg 3206, Level 16, State 1, Line 1
No entry in sysdevices for backup device 'ming'. Update sysdevices and rerun statement.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
0
 

Author Comment

by:turbot_yu
ID: 17963312
use
RESTORE FILELISTONLY
FROM  DISK = 'd:\db\BACKUP\ming.Bak'


got

ming      D:\DB\ming.mdf      D      PRIMARY      2097152      35184372080640      1      0      0      3ED48254-3414-4A20-B79E-8099EA31F3AC      0      0      1376256      512      1      NULL      18000000024400092      54374E32-4B54-490F-82A3-3FF89BE68869      0      1
ming_log      D:\DB\ming_log.ldf      L      NULL      1310720      2199023255552      2      0      0      84604128-9BC9-43F4-A872-99D31E4DDC32      0      0      0      512      0      NULL      0      00000000-0000-0000-0000-000000000000      0      1
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17963421
oops sorry ...
This will work

RESTORE DATABASE ming_test
   FROM DISK = 'd:\db\BACKUP\ming.Bak' ------------------<---ming
   WITH RECOVERY,
   MOVE 'Ming' TO 'D:\db\Ming_Test_data.mdf',
   MOVE 'Ming_log'  TO 'D:\db\Ming_Test_log.ldf'
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 17963440
FYI
RESTORE DATABASE ming_test FROM
   DISK = 'd:\db\BACKUP\ming.Bak' -- this is the Backup location, in your case backup is on Disk so yu need to put the path of the filename also
   WITH RECOVERY,
   MOVE 'Ming' TO 'D:\db\Ming_Test_data.mdf',  ------------ 'Ming' is the name of your datafile (the first column value u get when u run the RESTORE FILELISTONLY
   MOVE 'Ming_log'  TO 'D:\db\Ming_Test_log.ldf' ------------
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

738 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