欢迎进入windows社区论坛,与300万技术人员互动交流 >>进入
1: v_sys_contractions (获取系统连接数)
select count(*) as connections from master.sys.sysprocesses
2: v_sys_db_contractions(获取某数据的连接数)
select hostname, program_name, hostprocess, cmd, spid, kpid, blocked, waittype,waittime, lastwaittype, waitresource, dbid, uid, cpu, physical_io, memusage,login_time,
last_batch, ecid,open_tran, status, sid, nt_domain, nt_username, net_address, net_library,loginame, context_info, sql_handle, stmt_start, stmt_end, request_id
from master.sys.sysprocesses
where (dbid =
(select dbid
from master.sys.sysdatabases
where (name = 'xxdbname')))
3:v_sys_net_conractions(获取网路地址连接数)
select count(distinct net_address) - 1 as connectnum from master.sys.sysprocesses
4: v_sys_user_contractions(获取用户连接数)
select cntr_value as user_connections
from master.sys.sysperfinfo as p
where (object_name = 'sqlserver:general statistics')
and (counter_name = 'user connections')
