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;
But it's still hanging after 7 min.
但7分钟后它还在悬着。
I want this because I need to test the scenario.
我想要这个,因为我需要测试这个场景。
If it's even possible?
如果这是可能吗?
2 个解决方案
#1
165
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
#2
20
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
或与NO_WAIT一起使用,以不挂起和不杀死现有连接。有关详细信息,请参阅http://www.blackwasp.co.uk/SQLOffline.aspx
#1
165
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
#2
20
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
或与NO_WAIT一起使用,以不挂起和不杀死现有连接。有关详细信息,请参阅http://www.blackwasp.co.uk/SQLOffline.aspx