SCENARIO
I'm trying to perform some offline maintenance (development [gs database] restore from live backup) on my dev database, but the 'Take Offline' command via SQL Server Management Studio is performing extremely slowly - on the order of 30 minutes plus now.
SOLUTION
There is most likely a connection to the DB from somewhere (a rare example: asynchronous statistic update)
To find connections, use sys.sysprocesses:
USE master SELECT * FROM sys.sysprocesses WHERE dbid = DB_ID('MyDB')
To force disconnections, use ROLLBACK IMMEDIATE:
USE master ALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
SOURCE | LINK | LANGUAGE | ENGLISH |
Hey dude, did you know? Extreme wait-time when taking a SQL Server database offline – http://heelpbook.altervista.org/?p=34955 (Visit us on http://www.heelpbook.net) – Enjoy!
Extreme wait-time when taking a SQL Server database offline http://heelpbook.altervista.org/2012/extreme-wait-time-when-taking-a-sql-server-database-offline/ via @HeelpBook