'SSMS - Restore database failed because .mdf cannot be overwritten
I am trying to restore a DB from the backup. Suddenly, it is giving me the following error everytime while trying to restore.
Restore of database 'Something_Secret' failed.
The file 'C:\Some\Path\Something_Secret.mdf' cannot be overwritten. It is being used by database 'Something_Secreter'.
How to get rid this of error?
Solution 1:[1]
Don't use the UI for this, since this won't be the last thing it gets wrong for you. Learn the RESTORE DATABASE command.
RESTORE DATABASE Something_Secret_NewName
FROM DISK = 'D:\Baseline\Path\To\Something_Secret.bak'
WITH REPLACE, RECOVERY,
MOVE 'Something_Something_Logical_Primary'
TO 'C:\Program Files\...\Something_Secret_NewName.mdf',
MOVE 'Something_Something_Logical_Log'
TO 'C:\Program Files\...\Something_Secret_NewName.ldf';
If you want more specific guidance, show the output of:
RESTORE FILELISTONLY FROM DISK = 'D:\Baseline\Path\To\Something_Secret.bak';
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Aaron Bertrand |
