How to force a SQL Server 2008 database to go Offline

前端 未结 2 2041
日久生厌
日久生厌 2020-12-22 17:09

How do I force my Database to go Offline, without regard to what or who is already using it?

I tried:

ALTER DATABASE database-name SET OFFLINE;


        
相关标签:
2条回答
  • 2020-12-22 17:30

    You need to use WITH ROLLBACK IMMEDIATE to boot other conections out with no regards to what or who is is already using it.

    Or use WITH NO_WAIT to not hang and not kill existing connections. See http://www.blackwasp.co.uk/SQLOffline.aspx for details

    0 讨论(0)
  • 2020-12-22 17:32

    Go offline

    USE master
    GO
    ALTER DATABASE YourDatabaseName
    SET OFFLINE WITH ROLLBACK IMMEDIATE
    GO
    

    Go online

    USE master
    GO
    ALTER DATABASE YourDatabaseName
    SET ONLINE
    GO
    
    0 讨论(0)
提交回复
热议问题