关闭与特定数据库的所有连接而不关闭整个服务
我们在单个 SQL Server 2000 实例中拥有一些数据库,其中之一是沙箱。我的老板需要能够使用我没有源的实用程序通过沙箱恢复新数据。如果有人连接到沙箱,此类恢复就会失败。
我访问它的另一个应用程序使用连接池,并且可能有人使用其他应用程序来访问我无法控制的沙箱。
如何在不影响同一实例上运行的任何其他数据库的情况下启动沙箱中的每个人(包括池连接)?
(我已经看到使用 Management Studio 2008(从 2008 Express 开始)的解决方案,但是 a) 我需要能够从命令行或脚本以某种方式执行此操作,以便我的老板可以在不安装 Management Studio 的情况下运行它,并且b)他们谈论的上下文菜单选项似乎并不存在。)
We have some databases in a single SQL Server 2000 instance, one of them being a sandbox. My boss needs to be able to restore fresh data over the sandbox using a utility I don't have the source to. Such restores fail if anyone is connected to the sandbox.
Another app I have accessing it uses connection pooling, and also there might be people using other apps to access the sandbox that I can't control.
How can I boot everyone off the sandbox, including the pooled connections, without touching any of the other databases running on the same instance?
(I've seen solutions out there that use Management Studio 2008 (from 2008 Express), but a) I need to be able to do it from the command line or a script somehow so my boss can run it without installing Management Studio, and b) the context menu options they talked about didn't seem to be there anyway.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在网上找到了它:
ALTER DATABASE db SET SINGLE_USER WITH ROLLBACK IMMEDIATE
创建一个运行此恢复的 sp,然后将其恢复为常规。
(更改数据库 foo 设置多用户;)
I've found it on the web:
ALTER DATABASE db SET SINGLE_USER WITH ROLLBACK IMMEDIATE
create a sp that run this restores, and then restore it to regular.
(ALTER DATABASE foo SET MULTI_USER;)