Rename Database

  • How can I rename database x to database y and all the physical files?

    Thanks.

    Phil

     

  • To rename db you can use sp_renamedb proc or ALTER DATABASE statement. Renaming of physical files is not so straightforward:

    1.detach db from the server (sp_detach_db proc)

    2.rename the file(s)

    3.attach db back to the server (sp_attach_db proc)

    This will require disconnection of all users from the database and some db downtime.

    In fact you don't have to use sp_renamedb proc or ALTER DATABASE - you can specify new db name on attaching. Also make sure that logical file names correspond to db name and physical names.

     

  • Follow Martin's advice.

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

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