Extreme wait-time when taking a SQL Server database offline

Send Us a Sign! (Contact Us!)
Word PDF Epub Text
XML OpenOffice XPS MHT

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.

[tweet]

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

2 thoughts on “Extreme wait-time when taking a SQL Server database offline”

Comments are closed.