2012年3月20日星期二

disconnecting all users

How can I disconnect all other users from a SQL Server database, except for the one that issues the command
Go to www.dbmaint.com and look for the Utility stored procedures there...
Tibor has a proc that will kill all users connected to a particular
database...You can change it to execlude the spid it runs under, OR simply
move to another db..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Craig HB" <CraigHB@.discussions.microsoft.com> wrote in message
news:C97A47BF-E76C-4EAD-BA49-41496FB5E104@.microsoft.com...
> How can I disconnect all other users from a SQL Server database, except
for the one that issues the command
|||Try this:
use yourdb
go
alter database yourdb
set single_user with rollback immediate
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Craig HB" <CraigHB@.discussions.microsoft.com> wrote in message
news:C97A47BF-E76C-4EAD-BA49-41496FB5E104@.microsoft.com...
> How can I disconnect all other users from a SQL Server database, except
for the one that issues the command
|||ALTER DATABASE YourDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
USE YourDatabase
GO
... You've now set it to single user mode and then you've become that single
user.
"Craig HB" <CraigHB@.discussions.microsoft.com> wrote in message
news:C97A47BF-E76C-4EAD-BA49-41496FB5E104@.microsoft.com...
> How can I disconnect all other users from a SQL Server database, except
for the one that issues the command
|||those Utility stored procedures are really useful
thanks for letting me know about them
- Craig

没有评论:

发表评论