Restoring copy of Database in same file as Original

  • I currently restore a backup of my production database in the same physical data and transaction log files as the production database.  I just change the MDF and LDF the name to that of my 2nd database during the restore. I noticed they both share the same file name of Southwood_Data even though they have different MDF and LDF names.  Should I be concered about this?

    I bet I shouldn't be restoring it to that same file as the production either should I?

     

  • Josh

    Different databases can have files with the same logical names.  We have this a lot where we use multiple copies of the same database on the same server for testing.  Obviously if you tried to use the same physical name, your restore would fail.

    John

  • You can change the logical names of the mdf and ldf files as well too to be consistant. You'll need to do this right after the restore with this little code piece:

     alter database database_name

      modify file (name=old_database_name_Data, newname=new_database_name_Data)

     alter database database_name

      modify file (name=old_database_name_Log, newname=new_database_name_Log)

     go

     checkpoint

     go

    and don't forget:

     exec new_database_name..sp_changedbowner 'sa'

     go

     checkpoint

     go

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

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

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