Monday, March 26, 2012

Restore Database Question

Hello There,

I have a question about Restoring a database. How do I restore an existing Backup file of a database to a different database ?

For example, I have a backup file "a.bak", of the database name "a". This database has original file names as "a_data.mdf" and "a_log.ldf".

Can I restore this bak up file to a new database, say "b" which would have corresponding original file name as "b_data.mdf" and "b_log.ldf" ?

Please show me how to do this with window interface, if you can.

I would appreciate very much.

-pnnIn Enterprise Manager, right-click on Databases and select All Tasks, Restore Database.
In the Restore as database box, enter a new database name, or the name of the db you want to overwrite.
Select Restore: From device. Click Select Devices. If there is a device listed, click the Remove button (this doesn' actually affect the device!). Not click the Add button and browse/select the database file you want to restore.
Back out ot the first dialog, then go to the options tab.
Your logical file names can remain the same, but your physical file names should already have the name of your new database.
Make sure the Recover completion state option is set to leave the database operational, and then click OK.

Let us know if you have any other questions about this. Don't sweat it, because its very routine.

blindman|||Thank you for your prompt response!

You are NOT BLIND at all, Blind Man ! You're great !|||hi!

our company used to have our web site (and the DB) hosted and managed by our vendor. we are now in the process of migrating it to our in house servers.

so i need to migrate the DB too (SQL Server). so far i got .bak file. do i need any other files to restore the db (like .mdf, etc)?

thanks,
JN.|||your .BAK file is all you need. But I would consider making backups of your system db's as well, unless you have no DTS packages, scheduled tasks, backup history to care for, and logins.|||i'm getting this error (attached).|||jnurbek,
Complete the tasks that blindman posted.

It is possible that the database is trying to restore to a drive location that is not valid.

Regards|||All that error is telling you is that you are trying to restore a database that has a different location for the log and data files than the destination database has. Example: if I had

db1
data file - c:\db1.mdf
log file - c:\db1.ldf

and tried to restore a database that was

db2
data file - d:\db2.mdf
log file - d:\db2.ldf

it would give me your error, it tells you what you need to do by saying use the "with move" option.

For the above example you would write

RESTORE DATABASE db1
FROM DISK= 'wherever you have your backupfile.bak'
WITH RECOVERY,replace,
MOVE 'db2_data'
TO 'c:\db1.mdf',
MOVE db2_log'
TO 'c:\db1.ldf'

HTH|||thanks! i figured it out. i just changed the localtion from d:\ to c:\ and everything worked.|||damn it! i could restore the db on my local machine but when i tried on the server i get the following error. any idea? thanks.|||What were the options and parameters you were using in your restore?

Also, consider using the RESTORE DATABASE command through SQL. Not everything has to be done through #*(&$^# wizards!

blindman|||Sounds like you're running different editions on your PC and the server.

No comments:

Post a Comment