April 23, 2009 at 11:05 pm
I WANT TO KNOW TO FIND HOW MANY USERS ARE PRESENTLY
CONNECT TO THE SQLSERVER
April 23, 2009 at 11:17 pm
Use select * from sysprocesses.
U can also use sp_who2 stored procedures which is an undocumented one.
April 24, 2009 at 3:22 am
you can use below query:
select spid, status, loginame, hostname, blocked, db_name(dbid), cmd from master..sysprocesses where db_name(dbid) = 'yourdb'
Manoj
April 24, 2009 at 6:31 am
Use sp_who2
[font="Comic Sans MS"]+++BLADE+++[/font]:cool:
April 24, 2009 at 6:38 am
As manoj said, query is more efficiant than sp_who or sp_who2
select spid, status, loginame, hostname, blocked, db_name(dbid), cmd from master..sysprocesses where db_name(dbid) = 'yourdb'
Rajesh Kasturi
May 8, 2011 at 10:19 pm
Hello
I have been monitoring the following counter SQLServer: General Statistics\User Connections through performance monitor but the user connection count is lower than the number of rows returned by sysprocesses, sp_who or sp_who???
May 8, 2011 at 10:30 pm
matthew.peters (5/8/2011)
HelloI have been monitoring the following counter SQLServer: General Statistics\User Connections through performance monitor but the user connection count is lower than the number of rows returned by sysprocesses, sp_who or sp_who???
sp_who or sp_who2 returns the details for all the connections to sql server instance. These SQL server connection are generally Categorised in 2 parts 1. Sql server connections(Backgroud processes)
2. User Connections. Generally spids <50 denotes System connection.
So, when you use SQLServer: General Statistics\User Connections through performance monitor
It only returns user connections on the Instance.
To get the user connection details on any instance you could also run.
Select * from Master..sysprocesses where spid >50
I hope it is understood now..
Regards,
Sachin
May 8, 2011 at 10:35 pm
Rajesh kasturi (4/24/2009)
As manoj said, query is more efficiant than sp_who or sp_who2select spid, status, loginame, hostname, blocked, db_name(dbid), cmd from master..sysprocesses where db_name(dbid) = 'yourdb'
Sorry but i contradict on this statement, the query has nothing to do with what sp_who or sp_who2 returns.
Infact, you have modified the query based on your requirement.
The OP said he wants the list of all sql server connections but your query is confined to a specific database only. An instance could host more than 1 user database so running the above query could result only connection made on a specific user DB ,rather all the connections on the instance as requested by OP.
Correct me if i am wrong..
Regards,
Sachin
May 8, 2011 at 11:24 pm
You can also check in the 'sys.dm_exec_sessions' view to get the details against the 'session_id' which is the SPID in the sysprocesses table!
Thanks.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply