Restore database overwirte defaults

  • I've restored a database on a test server as the same name as an existing database but in a different directory.  Noticing that the original database files are missing and the properties of the database in sql are pointing to my new restored directory.  Is my original mdf gone?  I did not have the option to overwrite existing database check in the restore settings, just failed to rename it to database2 before restoring.  Here is a breakdown of what I have done:

    Old DB:  database1
    Location: C:\program files\blah\blah\blah\Data\database1.mdf
    Name: MyDatabase

    New DB: dabase2
    Location:  C:\restore\database2.mdf
    Name: MyDatabase

    Sql mgmt studio is now saying MyDatabase is poing to the database2 location and database1 is not in is orginial directory.  Assuming mgmt studio may have automatically removed to original file database1 and repointed.  Can anyone confirm this is native behavior by the mgmt studio restore process and no prompting by the restore process?

    Thanks,
    MB

  • As two database with same name can not exist on same SQL instance , I think you have performed restore database with replace option. Restore with replace option always removes original database files and restored database will point to new database files specified at the time of restore.

    -----------------
    Aditya Rathour
    SQL DBA

    Not Everything that is faced can be changed,
    but nothing can be changed until it is faced.

  • Since the .mdf file was not overwritten, you can probably just reattach it. However, as was noted, you can't have two databases with the same name, even if the files are in different locations. Try renaming the existing database and then using attach to get the old one back on the system.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply