A production environment, a line of the environment, the online environment of the data problems in the production environment does not appear, so you need to restore the line database to the production environment, but every time the restoration of the resignation database is in use, can not be restored, but the naked eye is not visible, So you need to query out the database connection and force the disconnection.
1. Query the maximum number of users that SQL Server allows simultaneous connections
SELECT @ @MAX_CONNECTIONS
2. Querying the current connection information for the specified database
SELECT * from WHERE inch ( SELECT from master.dbo.sysdatabases WHERE NAME= 'yourdatabasename'-- The specified database name )
Or
SELECT * from WHERE db_name = ' YourDatabaseName '
The meanings of each field in table master.dbo.sysprocesses see http://www.cnblogs.com/buaaboyi/archive/2010/04/06/1705142.html
3. Force shutdown of database connections in SQL Server
Kill Wu -- 54 is the SPID, which is the SQL Server session ID.
Querying the number of SQL Server database connections and disconnecting