how you can rename a database ?

 Posted by Neeks on 3/5/2009 | Category: Sql Server Interview questions | Views: 6348
Answer:

o rename a database first get the database into Single user mode . by using the query below ( run these query in query analyzer)

ALTER DATABASE DBMydb SET SINGLE_USER WITH ROLLBACK IMMEDIATE

then rename the database using sp_rename

sp_renamedb 'DBMydb', 'DBmydb_new'

then change the access mode of the database to multiuser

ALTER DATABASE DBmydb_new SET MULTI_USER


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response