开发者

Closing all connections to a particular database without downing the whole service

开发者 https://www.devze.com 2022-12-09 15:03 出处:网络
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.开发

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. 开发者_JAVA技巧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.)


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;)

0

精彩评论

暂无评论...
验证码 换一张
取 消