Extreme wait-time when taking a SQL Server database offline

前端 未结 17 946
有刺的猬
有刺的猬 2021-01-29 17:05

I\'m trying to perform some offline maintenance (dev database restore from live backup) on my dev database, but the \'Take Offline\' command via SQL Server Management Studio is

17条回答
  •  花落未央
    2021-01-29 17:50

    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
    

提交回复
热议问题