【转】查看sql server 数据库连接数
SELECT * FROM
[Master].[dbo].[SYSPROCESSES] WHERE [DBID]
IN
(
SELECT
[DBID]
FROM
[Master].[dbo].[SYSDATABASES]
WHERE
NAME='databaseName'
)
sql 断开所有数据库连接
declare @kid varchar(8000)
set @kid= ' '
select @kid=@kid+ ' kill '+cast(spid as varchar(8))
from master..sysprocesses
where dbid=db_id( 'databaseName')
Exec(@kid)
![](http://www.cnblogs.com/images/cnblogs_com/xsmhero/20091027.jpg)