Extreme wait-time when taking a SQL Server database offline

前端 未结 17 914
有刺的猬
有刺的猬 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:34

    To get around this I stopped the website that was connected to the db in IIS and immediately the 'frozen' 'take db offline' panel became unfrozen.

    0 讨论(0)
  • 2021-01-29 17:35

    In my case, the database was related to an old Sharepoint install. Stopping and disabling related services in the server manager "unhung" the take offline action, which had been running for 40 minutes, and it completed immediately.

    You may wish to check if any services are currently utilizing the database.

    0 讨论(0)
  • 2021-01-29 17:36

    Do you have any open SQL Server Management Studio windows that are connected to this DB?

    Put it in single user mode, and then try again.

    0 讨论(0)
  • 2021-01-29 17:37

    In my case I had looked at some tables in the DB prior to executing this action. My user account was holding an active connection to this DB in SSMS. Once I disconnected from the server in SSMS (leaving the 'Take database offline' dialog box open) the operation succeeded.

    0 讨论(0)
  • 2021-01-29 17:40

    I tried all the suggestions below and nothing worked.

    1. EXEC sp_who
    2. Kill < SPID >

    3. ALTER DATABASE SET SINGLE_USER WITH Rollback Immediate

      ALTER DATABASE SET OFFLINE WITH ROLLBACK IMMEDIATE

      Result: Both the above commands were also stuck.

    4 . Right-click the database -> Properties -> Options Set Database Read-Only to True Click 'Yes' at the dialog warning SQL Server will close all connections to the database.

    Result: The window was stuck on executing.

    As a last resort, I restarted the SQL server service from configuration manager and then ran ALTER DATABASE SET OFFLINE WITH ROLLBACK IMMEDIATE. It worked like a charm

    0 讨论(0)
  • 2021-01-29 17:44

    In SSMS: right-click on SQL server icon, Activity Monitor. Open Processes. Find the processed connected. Right-click on the process, Kill.

    0 讨论(0)
提交回复
热议问题