question

Zahid avatar image
Zahid asked

number of logins to the application

How can I see, how many users are logged in to my application at the moment? **EDIT from comment** Sorry, i was looking for the connect through the application. my application is build on SQL server 2008r2, .Net, etc. from the sql server i can not see how many users are currently connected to the application. the number is can see using sql [sp_who2 'active'] is not the correct figure
sql-server-2008-r2
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

KenJ avatar image KenJ commented ·
What kind of .NET application? Where you get the information depends on whether it's an IIS application, a WCF or Remoting Services application, or a plain-old fat-client-server application. I would also recommend stackoverflow.com or serverfault.com as sites that would be more non-SQL Server application development or application administration specific.
0 Likes 0 ·
JohnM avatar image
JohnM answered
Assuming that your users have corresponding logins for a database on the server, you can use a built-in system stored procedure 'sp_who' or 'sp_who2' to display to who is currently logged into the SQL Server. The latter will give you more detailed information about the connection. You can also use the activity monitor to see the list of connections. You can also use DMV 'sys.dm_exec_sessions'. Was there something specific you were looking for or just a count? Hope this helps!
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Zahid avatar image Zahid commented ·
Sorry, i was looking for the connect through the application. my application is build on SQL server 2008r2, .Net, etc. from the sql server i can not see how many users are currently connected to the application. the number is can see using sql [sp_who2 'active'] is not the correct figure.
0 Likes 0 ·
Fatherjack avatar image
Fatherjack answered
Your question refers to counting people logged in to your 'application' in many places. I am not sure of your exact meaning. In the strictest terms the SQL Server will have no knowledge of the people using the application until they do something in that application that elicits a connection to a database. Take as an example people using Excel. SQL Server has no idea how many (if any) staff are using Excel until one of them makes a connection to a database. Once a connection is made to SQL Server to access data in some way then SQL Server will keep track of connections and serve data accordingly. There are many ways that the number of connections (spids) on a SQL Server database will be different from the number of people using an application at the same point in time. It also is possible, for example, for an application to have a single user logged in but be written in such a way as it opens multiple connections to a database. Trying to use SQL Server functions and statistics to assess application user numbers will never be accurate. If you do need the details of how many people have logged in to your application then you will need some sort of user tracking functionality in your application. A mechanism, possibly itself writing to a SQL table, that counts as users log in and out and then you could assess how many are logged in at any one time. If you need to find the number of connections between an application and a SQL Server then sp_who, sp_who2, sp_who3 (eg http://mrdenny.com/applications/sp_who3 - one of many variants) and sp_who2k5 ( http://blogs.msdn.com/b/chadboyd/archive/2007/08/15/sp-who-for-sql-2005-sp-who2k5.aspx) will all help you locate and assess the details.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.