Thursday, September 11, 2014

Rename Database using SQL Query

Hi,

Use the following SQL Query to rename the database name using management studio.


ALTER DATABASE "old database name" MODIFY NAME = "new database name"


























IF SQL Not allowed to modify database name because it is in use. Than you can update it as following

1.       Set the database to single user only by following query
       ALTER DATABASE "YourDatabaseName" SET SINGLE_USER WITH ROLLBACK IMMEDIATE

2.       Now you able to run database rename query
ALTER DATABASE "old database name" MODIFY NAME = "new database name"

3.       Again set the database to multiple user by using following query
ALTER DATABASE "YourDatabaeName" SET MULTI_USER WITH ROLLBACK IMMEDIATE



2 comments:

  1. Its real use full query nilesh.
    Thank you for share

    ReplyDelete
  2. You are welcome. Please keep in touch will we be do better

    ReplyDelete