Change .mdf & .ldf after restoration

  • Hi All,

    I know that this question is like a "newbie" question, but please help me on this.

    How can I rename/change the .mdf & .ldf file name after I attach(restore) the database.

    for example, the file name is old.mdf and old.ldf, I attach it as database: new.

    then, I want to change the filename to be new.mdf & new.ldf

    Is there any sql querry to do this?

    Thank you very much for your answers

     

    Cheers,

    Andy J

  • Pretty simple

    1) Detach the database

    2) Rename the files.

    3) Attach the database. You'll probably have to put the path & file name in the "attch" screen.

    4) all done

  • Hi Andrew,

    If renaming the database is your only concern then, u can try this query,

    sp_renamedb 'Olddbname','Newdbname'

    Cheers,

    Raghu Pyapili

  • That will just rename the database.  If you need to rename the files making up the database you must do that when the database is offline whether through a detatch or restore.

  • It Works

    Thanks for the advise, guys

     

    Best Regards,

    Andrew J.

Viewing 5 posts - 1 through 4 (of 4 total)

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