How to Rename a SQL Server Database

Sometimes it is useful to rename a SQL Server 2000 Database.


Typical scenarios include:

  1. Moving a development database into production.
  2. Redirecting the front-end of an application to a different version of the back-end.

The Approach 

You cannot rename a database within Enterprise Manager. Instead, you can execute a command in Query Analyzer.

You use sp_renamedb to rename the database:

EXEC sp_renamedb ‘<old name>’, ‘<new name>’ 


  1. The command must be executed by a member of the ‘sysadmin’ fixed server role.
  2. The database must be renamed in ‘single-user’ mode.
  3. You must be in the master database to execute sp_renamedb.

Example Script

To rename ‘oldName’ to ‘newName’: 

USE master


EXEC sp_dboption oldName, ‘Single User’, True

EXEC sp_renamedb oldName, newName

EXEC sp_dboption newName, ‘Single User’, True


  1. You should ensure that there are no references to the old database name in the database that is renamed.
  2. The names of the database files / filegroups will not be changed as a result of renaming the datbase.

10 Responses to How to Rename a SQL Server Database

  1. Uhtruxyj says:

    Hold the line, please lolita bbs

  2. Cpkdvpgw says:

    Not available at the moment 13yo Teen Models

  3. Ajxpkvdq says:

    How many would you like? underground lola love bbs She is always a treat. Does any one know if she has a little latina in her? She almost looks like a latina girl with bleached hair and light contacts. either way, goddamn.

  4. Osqepcyf says:

    Would you like a receipt? best place bbs mindy vega is fucking FLAWLESS!!! i couldn’t make it through the whole video. i came the same time she did.

  5. AnniTymn says:

    DEAR DR. NERDLOVE anxiety test free nhs: thank you for all you’ve written and done over the years, which has done wonders for my confidence. I’m 29, with…
    anoxia perinatal
    Head injury lawyers in gulfport, ms and biloxi, ms – personal injury lawyer car accident attorney in gulfport, ms anoxia perinatal

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: