当前位置:Gxlcms > mysql > 如何获取SQLServer数据库的连接数

如何获取SQLServer数据库的连接数

时间:2021-07-01 10:21:17 帮助过:92人阅读

欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入 1: V_SYS_CONTRACTIONS (获取系统连接数) SELECT COUNT(*) AS CONNECTIONS FROM master.sys.sysprocesses 2: V_SYS_DB_CONTRACTIONS(获取某数据的连接数) SELECT hostname, program_name, ho

欢迎进入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')

人气教程排行