Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to rename database? 1

Status
Not open for further replies.
Hi Andy

To rename a database use the stored procedure sp_renamedb
The following code
renames a database from "Fred" to "Tom".


sp_renamedb 'Fred', 'Tom


This should work in any version of SQL Server.

Hope this helps
Bernadette
 
yes it works. however I've to set the DB to single user mode first. I've tried it in 2000, I can rename DB when I set the DB to be 'single user' mode or 'dbo user only' mode. but in 6.5, I can only rename DB when it's in 'single user' mode, but can't rename when in 'dbo use only' mode.
another thing is that, in 2000 I can only do the whole process in query analyser, coz I can't open a DB in both the QA and EM, when it's in 'single user' mode.
thanks. :> Please visit my WebCam!!
 
Hi Andy

Oopps ! sorry about that I forgot to mention it should be in 'single user mode'.
The reason you cant have QA and EM open at the same time is it counts it as another process and the dbo must have exclusive use of the database. So you have to close QA.
I am glad it worked and you got your problem sorted.

Bernadette
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top