Database is in Transition. try the statement later: SQL Server

Problem:

I was trying to take the database offline to perform some maintenance on one of our QA server.

We have got a strange error "Database is in Transition. try the statement later Error 952"

Even i was not able to run the sp_who and sp_who2 also as it was also giving the same error.


Resolution:  What i have tried?

I closed the SSMS (SQL Server Management Studio) and restarted it again.

Then to confirm and check for any blocking query, i ran sp_who and sp_who2 and it ran successfully.

 Then to make Database offline/online i have used the below command and it worked like a charm :)

USE master
GO

ALTER DATABASE <db_name>

SET OFFLINE WITH ROLLBACK IMMEDIATE ... ... ALTER DATABASE <db_name> SET ONLINE

Its a strange error with SQL-2005 Management Studio or we can say a bug.

This small issue can cause a big headache for someone.. hope this will helpful. :)