Rename a Database in SQL Server

Introduction

We can rename a user-defined database in SQL Server by using SQL Server Management Studio or Transact-SQL. System databases cannot be renamed. The database name cannot be changed while it is online and other users are accessing the database. We can set a database in single-user mode to close any open connections.

Set the database to single-user mode

By TSQL

By SSMS

Right-click on Database > Properties

Option > Other options > Restrict access > SINGLE_USER

Rename SQL Server database using T-SQL

This command is useful for SQL server 2005, 2008, 2008R2, 2012 and onward

Or

By SSMS

Set the database to multi-user mode

By TSQL

By SSMS

Right-click on Database > Properties > Option > Other options > Restrict access > MULTI_USER

Facebook Comments Box
Please like or share this post if you found it helpful, thank you.
Share on Facebook
Facebook
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin
Email this to someone
email
Print this page
Print

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *