Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Number of users accessing the Database

Author  Topic 

reoaran
Starting Member

20 Posts

Posted - 2010-08-03 : 13:20:13
I was asked to find the total number of users accessing a db. I just right clicked the database and found "number of users" to be 15 and hence sent 15. But they told me there are more than 1000 users accessing the db. Am i looking in the wrong end or Is there any other specific way to find this out ?. What is the use "number of users" in the database properties ?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-03 : 13:26:12
Run this to see how many concurrent connections there are:

SELECT COUNT(*)
FROM master..sysprocesses
WHERE dbid = DB_ID('YourDatabaseNameGoesHere')


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

reoaran
Starting Member

20 Posts

Posted - 2010-08-03 : 13:48:02
Yes Tara.. we could check for the connections there ... But any specific way to find the number of users accessing the db ? Any way to find them indirectly using sys.dm_tran_locks or exec requests ... ?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-03 : 13:49:52
Why do you need a separate way to query it when the query I provided gives you the data that you need?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

reoaran
Starting Member

20 Posts

Posted - 2010-08-03 : 14:15:39
I also get status apart from RUNNING and the connections that are inactive. And i have a small clarification if you can help... If there are 1000 users accessing the application in the front end that is connected to this database, then how many connections it would show in the sysprocesses
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-03 : 14:20:03
For your running/inactive question, is the question really how many users are running queries at this very moment? And if so, we'll need the next question answered...

For your 1000 users question, it depends on the application configuration. Does each user get its own SQL connection or is the application using connection pooling?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

reoaran
Starting Member

20 Posts

Posted - 2010-08-03 : 14:24:39
ok Tara.. great.. I ran the query sysprocesses you provided and i had an output of just 12. But they tell me that there are more than 1000 users connected to this database. Hope they are connected indirectly or the one you told Application pooling...
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-03 : 14:53:49
If there are 1000 users and only 12 connections, then they are using connection pooling. Their application will need to add the feature to track user access, possibly writing the data to a table.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -