sp_renamedb System Stored Procedure

Changes the name of a database.

Syntax

sp_renamedb oldname, newname

where

oldname
Is the original name of the database.
newname
Is the new name of the database. Names of objects and datatypes must follow the rules for identifiers.

Remarks

Only the system administrator can change the name of a database. The system administrator must put a database in single-user mode by using sp_dboption before renaming it, and must restore it to multi-user mode afterward.

Example

This example changes the name of the accounting database to financial.

sp_renamedb accounting, financial

Permission

Execute permission defaults to the system administrator.

Table Used

master.dbo.sysdatabases

See Also

CREATE DATABASE sp_depends
sp_changedbowner sp_helpdb
sp_dboption sp_rename