查看sqlserver连接数

select count(spid) as counts, 
status, 
hostname, 
dbname 
= case 
when dbid = 0 then null 
when dbid <> 0 then db_name(dbid) 
end 
from master.dbo.sysprocesses 
where spid >=0 and spid <= 32767 and status='runnable' and db_name(dbid)='数据库名' 
group by status,hostname, 

case 
when dbid = 0 then null 
when dbid <> 0 then db_name(dbid) 
end 
posted on 2011-05-26 10:52  一路前行  阅读(439)  评论(0编辑  收藏  举报