bobox00
asked on
How to restore a database
Trying to migrate an SQL database to a different server computer. I have backed up the database to a .bak file. When I try to restore, in the new SQL server (microsoft) it asks for which database to restore to. Do I create a blank database first? And should the blank database be the same name as the old one?
it is much easier just to create a blank DB you can name it what you want and then restore to that...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm a T-SQL nut so here is what I would do.
RESTORE DATABASE [DatabaseName] FROM DISK = N'E:\DatabaseName.bak' WITH FILE = 1, MOVE N'DatabaseName' TO N'E:\SQLData\DatabaseName. mdf', MOVE N'DatabaseName_log' TO N'F:\SQLData\DatabaseName. LDF', NOUNLOAD, STATS = 1
If you are not sure of the filenames to move them you can run
RESTORE FILELISTONLY FROM DISK = N'E:\DatabaseName.bak'
This will give you any info that you need to use with your MOVE statement.
RESTORE DATABASE [DatabaseName] FROM DISK = N'E:\DatabaseName.bak' WITH FILE = 1, MOVE N'DatabaseName' TO N'E:\SQLData\DatabaseName.
If you are not sure of the filenames to move them you can run
RESTORE FILELISTONLY FROM DISK = N'E:\DatabaseName.bak'
This will give you any info that you need to use with your MOVE statement.
ASKER
Thanks
You can restore it from the backup file you are using, you can rename the DB here too if you wish.
Check the path of the ldf and mdf file locations, are they the correct place for your log and data files on your server you are restoring on?
The last part is important too.
Goto the options tab (I am presuming you are using SSMS to do all this), and select the "leave database ready to use...." radio button.
Tony.