Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to restore a database over the existing one. This worked fine in the past, until all of a sudden, it doesnt.

I have clearly, in the past, attached the same database file under a different name and it now thinks that restoring a database over the current instance will overwrite the other instance as well hence giving me the following error:

Failed to restore database: The file 'E:\database\db.mdf' cannot be overwritten. It is being used by database 'ABC'.
File 'db' cannot be restored to 'E:\database\db.mdf'. Use WITH MOVE to identify a valid location for the file.

The file 'E:\database\db_log.ldf' cannot be overwritten.  It is being used by database 'ABC'.
File 'db_log' cannot be restored to 'E:\database\db_log.ldf'. Use WITH MOVE to identify a valid location for the file.

The big question: How do you delete references to the old database? How do you find what previous database instances were used even?

Thanks

share|improve this question
add comment

1 Answer

Try moving the conflicting files into a different directory/deleting them. The operation is basically being told to overwrite files that it sees to be there with something different. I had a similar problem on a test environment and discovered either deleting the conflicting files/moving them worked perfectly.

Also, have you tried to use the WITH REPLACE option under the restoration menu? I'm not entirely sure this works for an instance named differently, but with a same name it will overwrite it perfectly fine.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.