Home
 Index > Microsoft SQL Server > How to Clear SQL Server Database Connections

Microsoft SQL Server:  SQL Server 2005 Express Edition

How to Clear SQL Server Database Connections

Clear SQL Server database connections with a simple one-line statement.

Added on 25 Feb 2009

General Solutions:

Solution Summary:
Execute the following statement (replacing "DBName" with the database name) to clear all active SQL connections to the database.
Solution Details:

ALTER DATABASE [DBName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE

While the database should "immediately" return to multi-user after killing the other connections, you may find that it does not; and now users are unable to connect.  Therefore, after executing this statement, you may need to execute another:

ALTER DATABASE [DBName] SET MULTI_USER
Was this solution useful? Yes No Added on 25 Feb 2009
Rating: 

Copyright 2017 © E-Centric, Inc. | Terms of Use