Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

restoring a .bak file SQL SERVER 2005

Hello,

I have created a .bak file on file office machine and I want to restore this on my home machine. After creating a new GiftWeb database when I run the following statement to restore I am getting erros, please see attached.

use master
RESTORE DATABASE GiftWeb
FROM DISK = 'C:\G_DB\20091211.bak'
WITH REPLACE

Can someone please advise

Thanks
C
Msg 5133, Level 16, State 1, Line 2
Directory lookup for the file "D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\GiftWeb.mdf" failed with the operating system error 21(The device is not ready.).
Msg 3156, Level 16, State 3, Line 2
File 'GiftWeb' cannot be restored to 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\GiftWeb.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 5133, Level 16, State 1, Line 2
Directory lookup for the file "D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\GiftWeb_log.ldf" failed with the operating system error 21(The device is not ready.).
Msg 3156, Level 16, State 3, Line 2
File 'GiftWeb_log' cannot be restored to 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Gift_log.ldf'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 2
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.

Open in new window

0
charlie324
Asked:
charlie324
  • 2
  • 2
  • 2
2 Solutions
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
Try this syntax:

use master
GO
RESTORE DATABASE GiftWeb
FROM DISK = 'C:\G_DB\20091211.bak'
WITH MOVE 'ur_db_data_file_name' TO 'mdf_file_location',
MOVE 'ur_db_log_file_name' TO 'ldf_file_location'
GO

Replace the file names and file path before running it..
0
 
master135Commented:
You can do it rather simpler.
Log in to SQL as administrator.
Create an empty database GiftWeb
Right click on it - tasks - restore - database.
Choose "from device" - select file from which do you want to restore backup.
Then go to the Options tab.
Select overwrite existing database(it's empty now)
On "restore database file as" choose correct path(default path is shown as on computer where you created backup) where your new database files placed!!!!!!!!!
Click OK - that's all
0
 
charlie324Author Commented:
hi,
thanks for your input, i am not getting the following error message

Msg 3154, Level 16, State 4, Line 1
The backup set holds a backup of a database other than the existing 'GiftWeb' database.

Although I am 100% certain the .bak file is for the GiftWeb database...

please advise

thanks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
charlie324Author Commented:
>>i am not getting the following error message

Sorry, I meant to say that I am getting an error now when I try to restore. I have used both of the above 2 methods, please advise
0
 
master135Commented:
Actually I don't see the reason why doesn't it works. Check if database compability for newly created database and source database are the same. For examle databases from sql 2000 cannot be restored to sql 2005 if doesn't set database compability for 2000.
0

Featured Post

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!

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now