How To Create, Rename, Delete (Drop) A Database In MS Sql (Part 2/3)
First of all Open MS SQL Management Studio And Select your database.
For Renaming a database, Right Click on the database Icon and select Rename.
Suggest a New Name for your database and press enter.
By this way we can Rename a database usng Management Studio.
You have two option when Renaming Database using code.
One is by using Alter Command and another is using Stored Procedure sp_renameDB.
Alter Command looks likes as follows
Alter database CurrentDatabaseName Modify Name = NewDatabaseName.
By Executing the above code we can Rename the Database.
Second way is by using Stored Procedure sp_renameDB.
Execute sp_renameDB 'CurrentDatabaseName' , 'NewdatabaseName'.
By Executing the above Stored Procedure, we can Rename the Database.