Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to Drop All Connections

Author  Topic 

gregoryagu
Yak Posting Veteran

80 Posts

Posted - 2008-08-08 : 12:55:46
Is there a command to drop all opens connections to a database?

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-08-08 : 14:09:04
one extreme option is:
alter database <dbName> set single_user with rollback immediate

of course then the DB is in single user mode until you alter it back.

Be One with the Optimizer
TG
Go to Top of Page

gregoryagu
Yak Posting Veteran

80 Posts

Posted - 2008-08-08 : 14:38:04
OK.

I also just found this:

sp_who

kill (the process id returned above)

Greg
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-08 : 14:42:10
I use code like this when I need more flexibility than ALTER DATABASE:
http://weblogs.sqlteam.com/tarad/archive/2007/02/08/60083.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-08-08 : 15:23:59
quote:
Originally posted by gregoryagu

Is there a command to drop all opens connections to a database?

Most servers have a power button on the back of the case.

e4 d5 xd5 Nf6
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-08-08 : 16:45:08
failing that, just unplug the entire rack.


elsasoft.org
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-08-08 : 18:54:43
Or burn the building down.

e4 d5 xd5 Nf6
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-08-08 : 19:36:18
or simply destroy the planet. here's a howto: http://qntm.org/?destroy

note: this might be more difficult in practice than what Tara suggested.


elsasoft.org
Go to Top of Page
   

- Advertisement -