Changing the name of a SQL database

前端 未结 4 757
北恋
北恋 2021-02-06 04:21

What is the correct procedure to rename a database?

Example: I have a database that I can access with SQL Server Management Studio and has a name like \"MyDatabase\". Ph

4条回答
  •  一整个雨季
    2021-02-06 04:55

    There are several ways to make this change, however to rename the physical database files at operating system level you will have to take the database offline

    sp_renamedb 'olddatabasename','newdatabasename'

    but make sure database is not in use.

提交回复
热议问题