If you right click a database in SSMS and select Tasks => Take Offline, you might find yourself staring at this dialog for hours, if there are active sessions running queries on your database.
Here’s how to force it to go offline, rolling back any current transactions. Replace [dbname] with the name of your database.
USE master GO ALTER DATABASE [dbname] SET OFFLINE WITH ROLLBACK IMMEDIATE GO
To get it back online, you can do this
USE master GO ALTER DATABASE [dbname] SET ONLINE GO
1 Comment
After watching SQL studio’s GUI hanging for half an hour this post was a life saver. Thank you!