File name vs location file name when attacching

  • When we want to make copy of a database to another server, most of the time we simply make a backup of the Mdf and Ldf files, restore them and rename the files on the new server, then we attach the files using a different database name. However the name under the properties still stays at the original database file name. How can I change that file name for my databases that I have attach or when I am attaching them? I want them to be consistant with the physical file name.

    thanks

  • Well, I think that what you should do is copy the files from the original server (It must be stopped) to the new server. Then attach those files without changing the names, and then execute sp_renamedb 'oldname','newname' to change the db name.

    If you just change the file name, the page that contains the header for info about the database still records the old name.

  • With SQL 2000 this is the syntax

    ALTER DATABASE <dbname> MODIFY FILE (NAME = <oldlogicalfilename>, NEWNAME = <newname>)

    with SQL 7 I don't recall there being a way.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • That worked. Thanks you guys for the fix for this.

    Mona

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

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