查看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
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