When database goes big it will difficult to do any administrative task and think if you have to change the name of database; then it will be major task. I got below error while changing database name on my test database, users were loged in and i was trying to change the name , database server quickly pop-up error . I tried 2-3 times error was same like below :
I followed below step to resolve this issue :-
ALTER DATABASE school SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
EXEC sp_renamedb N'school', N'SQLSchool';
message - The database name 'SQLSchool' has been set.
ALTER DATABASE SQLSchool SET MULTI_USER WITH ROLLBACK IMMEDIATE;