Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Restoring a backup into another database
Message
 
 
To
01/09/2010 18:50:54
General information
Forum:
Microsoft SQL Server
Category:
Backups
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01479690
Message ID:
01479696
Views:
43
>I did a backup of a database. I have the file as MyBackup.bak. In the same directory, I have created a new database name MyDatabase. How can I restore the backup into that database? Basically, the MyDatabase database has been created with different names for the Logical Name such as MyDatabase for the File Type and MyDatabase_log for the Log. If I try to restore the backup on that new database, it will try to overwrite the existing previous database because of the configuration of the .bak file. Basically, the goal is to obtain a restore in the same directory but on another database so I can start using it from that point for another Web site.

Here is a script:
RESTORE DATABASE [DbTest] FROM  DISK = N'C:\SQL DB Backups\AW.bak' WITH  FILE = 1,  
MOVE N'AdventureWorks_Data' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DBTest.mdf',  
MOVE N'AdventureWorks_Log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DBTest.ldf',  
NOUNLOAD,  REPLACE,  STATS = 10
If you do this in SSMS, type the new name in the restore to dialog (in the options). This is generated as MOVE option in RESTORE command.

See attached screen - you need to type the new name where I show - type here.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform