2

I have a code blog but a problem was occurred. In here my backup file is ISBANK.bak and database name is new database name. It doesn't contain anything. I want to add .bak file's content to a new database..

RESTORE DATABASE [DBName]
FROM DISK = 'D:\ISBANK.bak'
WITH REPLACE,
MOVE 'DBName' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008RR2\MSSQL\DATA\DBName.mdf',
MOVE 'DBName' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008RR2\MSSQL\DATA\DBName.ldf'

I am getting these errors:

Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL10.SQLSRV2008\MSSQL\DATA\OBERNET_DENEME.mdf" failed with the operating system error 3 (failed to retrieve text for this error. Reason: 15105).
Msg 3156, Level 16, State 3, Line 1
File 'OCEAN' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLSRV2008\MSSQL\DATA\OBERNET_DENEME.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL10.SQLSRV2008\MSSQL\DATA\OBERNET_DENEME.ldf" failed with the operating system error 3 (failed to retrieve text for this error. Reason: 15105).
Msg 3156, Level 16, State 3, Line 1
File 'OCEAN_log' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLSRV2008\MSSQL\DATA\OBERNET_DENEME.ldf'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

1

2 Answers 2

3

Edit

Remove WITH REPLACE

RESTORE DATABASE my_new_database FROM disk = 'E:\path_to_bak_file\database_name_634182143083281212.bak'
WITH
   MOVE 'the logical name from previous operation check row 1' TO 'E:\path_to_sql2008_file_onyour_machine\my_new_database.mdf',
   MOVE 'the logical name from previous operation check row 2' TO 'E:\path_to_sql2008_file_onyour_machine\my_new_database_log.ldf'
GO

You can also use the Restore utility available in SQL Server Management Studio (SSMS). This is a step by step process which lets yous select the .bak file and restore it as new database (which ever name you like for it).

Fire SQL Server Management Studio, connect to the server as admin, right click on the database node and select restore.

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

remove WITH REPLACE by 'WITH'
I try to what you said but it didn't work. maybe ı dont have permission. is it possible??
@Yunusemre the errors do not seem be related to permissions. Did you run in in master database? Did you remove the comma after with? You m ay also try to export it to a folder where you have full permission such as my documents, just to test it.
unfortunately occured the same problem
0

you have use default path for database restoration.

This will useful to you.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.