User Id :    Password :      New Member   Forgot Password
 
Disconnect all other user from SQL Server DB
Description In this codesnippet I will show you how you can disconnect all other user from SQL Server DB except your own.   No. of Views     1651
  Rating     0
Author Md. Moinuddin   Posted On     23 Oct 2011
Tags SQL SERVER    

Sample Code   Download Code



Many times we need all sql server connections to be closed except the connection in which our current query is running. For that we can try the following methods.


a)Search and kill all the connected users.
b)Stop and restart the database server, then issue the command.
c)Take the database offline etc.This is really a pain though has to be done.

The best way to do it by setting the database in single user by following commands:
 

ALTER DATABASE database_name SET SINGLE_USER WITH ROLLBACK IMMEDIATE

 

Do the job and set it back to multi user

 

ALTER DATABASE database_name SET MULTI_USER WITH NO_WAIT


 

 

About Author

About Author Moin is a project manager in Esoft company. His love to help people by writing technical articles. Md. Moinuddin
No Photo
 
Country India
Company e.Soft Technologies
Home Page N/A

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

     
Write your comment here.  
Comment
Verification Code   
  
    
 
Section sponsored by