Recover database and relocate MDF file

I will not restore my database, but the location path is not the same. How can I change this path (section)?

RESTORE DATABASE [MY_DATABASE] 
FROM  DISK = 'C:\Content.bak' 
WITH  FILE = 1,  
NOUNLOAD,  
STATS = 10

Error message:

Msg 5133, Level 16, State 1, Line 1
The directory search for the file "F: .... \ Content01.mdf" failed with an operating system error 3 (the text for this error could not be obtained. Reason: 15100).
Msg 3156, Level 16, State 3, Line 1 The
file 'Content01' cannot be restored to 'F: .... \ Content01.mdf'. Use WITH MOVE to determine the valid location of the file.
Msg 5133, Level 16, State 1, Line 1 The
search for the directory for the file "H: .... \ Content01_log.LDF" failed with an operating system error 3 (could not get the text for this error. Reason: 15105).
Msg 3156, Level 16, State 3, Line 1
The file "Content01_log" cannot be restored to "H: .... \ Content01_log.LDF". Use WITH MOVE to determine the actual location of the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified when planning the RESTORE statement. Previous posts provide detailed information.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE ends abnormally.

THANKS.

+5
source share
3 answers
RESTORE DATABASE [My_Database] 
FROM DISK = 'C:\Content.bak'
WITH MOVE 'MyDatabase_Data' TO 'C:\Data\MyDatabase_Data.mdf',
MOVE 'MyDatabase_Log' TO 'C:\Data\MyDatabase_Log.ldf',
REPLACE,
STATS=10
+12
source

Use the WITH MOVErestore command as described in this SO question .

+2
source

If someone is here because he is restoring a database with multiple files, each target file needs a new name. Using SQL Server 2008 R2, gui does not give an obvious hint and does not resolve it automatically.

+1
source

All Articles