sql - Count open datareaders/connections -
i asked following question: system.data.sqlclient.sqlexception (0x80131904). had through code , did find datareader not closed properly.
i still seeing exception in log file. there way count how many open connections/datareaders there database? have tried following sql statement:
select db_name(dbid) dbname, count(dbid) numberofconnections, loginame loginname, nt_domain nt_domain, nt_username nt_username, hostname hostname sys.sysprocesses dbid > 0 group dbid, hostname, loginame, nt_domain, nt_username order numberofconnections desc;
it returns 1 connection (the 1 have open in sql studio manager assume). why this? permissions issue?
try this:
select login_name, [program_name], count(session_id) [session_count] sys.dm_exec_sessions (nolock) group login_name, [program_name] order count(session_id) desc option (recompile);
Comments
Post a Comment