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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[b]EXEC sp_renamedb 'accounting', 'financial' Attempt is Failing[/b] 3

Status
Not open for further replies.

Apollo21

Programmer
May 2, 2003
70
0
0
US
When I am logged in as sysadmin and after restarting all aspects of 2000 SQL Server (agent etc.) I receive the following message when executing this stored proceedure (EXEC sp_renamedb 'accounting', 'financial')

Server: Msg 5030, Level 16, State 2, Line 1
The database could not be exclusively locked to perform the operation.

Does anyone have any thoughts on this? Thank you in advance.
 
Run this
Code:
-- Make the DB SINGLE user 
ALTER DATABASE accounting SET SINGLE_USER WITH ROLLBACK IMMEDIATE

--RENAME

sp_renamedb 'accounting', 'financial'

-- Make the DB multi user again
ALTER DATABASE financial SET MULTI_USER

Denis The SQL Menace
SQL blog:
Personal Blog:
 
That will happen when another process is connected to the database.

You can use sp_who to see what other processes are connected.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
If you are running this fr4om query analyser, make sure YOU are not in the DB you are trying to rename. You should not have 'accounting' in the dropdown box at the top that selects the db nane. I can't tell you how many times I have done this myself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top