how many concurrent users are connected to the database from an web application

  • Is there a query I can find out how many users currently from a .net application to connect to a SQL database?

    Thanks,

  • sqlfriends - Tuesday, May 23, 2017 5:14 PM

    Is there a query I can find out how many users currently from a .net application to connect to a SQL database?

    Thanks,

    Try this

       select count(*) from sys.dm_exec_sessions where database_id=db_id('db_name') and program_name='.Net SqlClient Data Provider'

  • VastSQL - Wednesday, May 24, 2017 3:30 AM

    sqlfriends - Tuesday, May 23, 2017 5:14 PM

    Is there a query I can find out how many users currently from a .net application to connect to a SQL database?

    Thanks,

    Try this

       select count(*) from sys.dm_exec_sessions where database_id=db_id('db_name') and program_name='.Net SqlClient Data Provider'

    Which will work as long as the program_name is filled in by the connection string. If it's not, you may not see this. It's not a required property in the connection strings.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Currently it returns 0. Possibly nobody is using the site.
    I believe there is no way to find out the connections at a particular past time.

    THanks

  • sqlfriends - Wednesday, May 24, 2017 10:05 AM

    Currently it returns 0. Possibly nobody is using the site.
    I believe there is no way to find out the connections at a particular past time.

    THanks

    No. There's nothing that logs connections automatically. You can use extended events to do that, but you have to set it up in order to have the information available.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply