Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Kill user connections

Status
Not open for further replies.

puterkrazy

Programmer
Aug 6, 2003
30
0
0
US
How can you programatically kill all SQL user connections using SQL?
 
thanks, i looked at this but it is more involved than what i am looking for. is there a simple command to kill all users on a database?
 
Hi,

Have a look at Alter Database command... u can set Database in a Single user mode...

ALTER DATABASE DBname SET SINGLE_USER

also u might want to look at Rollback option for this command...

ALTER DATABASE DBname SET SINGLE_USER ROLLBACK Immediate

Or

sp_dboption Dbname, 'Single User', True






Sunil
 
so does setting to SET_SINGLE_USER autmatically kill all other user connections?
 

Yes it will kill all the user connections...

Sunil
 
I get this error:
Database state cannot be changed while other users are using the database 'db'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top