如何在系统表中查询当前并发连接数SQL语句

解决方案 »

  1.   

    select count(distinct   hostname) as '连接'
    from master..sysprocesses  
    where hostname<>'' and dbid=db_id('my')1
      

  2.   

    --非 MARS 会话连接数
    select count(1) from sys.dm_exec_connections 
    where parent_connection_id  is null-- MARS 会话连接数
    select count(distinct parent_connection_id  ) from sys.dm_exec_connections 
    where parent_connection_id  is not null