Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. SQL Server pool size

SQL Server pool size

Scheduled Pinned Locked Moved C#
csharpdatabasesql-serversysadminquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DannyAdler
    wrote on last edited by
    #1

    Hi all, Is there a C# way for retrieving the number of currently opened sql-connections? Thanks in advance, Danny

    J 1 Reply Last reply
    0
    • D DannyAdler

      Hi all, Is there a C# way for retrieving the number of currently opened sql-connections? Thanks in advance, Danny

      J Offline
      J Offline
      Justin Perez
      wrote on last edited by
      #2

      DannyAdler wrote:

      Is there a C# way for retrieving the number of currently opened sql-connections?

      Yes. The SQL query to return the connections is:

      select * from sys.dm_exec_connections

      I suggest you create a stored procedure in your database, and call that SP from your C# app.

      I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

      D 2 Replies Last reply
      0
      • J Justin Perez

        DannyAdler wrote:

        Is there a C# way for retrieving the number of currently opened sql-connections?

        Yes. The SQL query to return the connections is:

        select * from sys.dm_exec_connections

        I suggest you create a stored procedure in your database, and call that SP from your C# app.

        I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

        D Offline
        D Offline
        DannyAdler
        wrote on last edited by
        #3

        Thanks for the reply man. Here's the query result: Invalid object name 'sys.dm_exec_connections'. Using SQL Server 2000... Any idea? Danny

        J 1 Reply Last reply
        0
        • J Justin Perez

          DannyAdler wrote:

          Is there a C# way for retrieving the number of currently opened sql-connections?

          Yes. The SQL query to return the connections is:

          select * from sys.dm_exec_connections

          I suggest you create a stored procedure in your database, and call that SP from your C# app.

          I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

          D Offline
          D Offline
          DannyAdler
          wrote on last edited by
          #4

          Found it on this dude's blog: http://sqljunkies.com/WebLog/sqldude/archive/2004/06/14/3146.aspx[^] Quoting: Now to obtain the current number of connections to the server, you can use: SELECT COUNT(*) AS CONNECTIONS FROM master..sysprocesses And just to get the user connections, omitting the system processes, use: SELECT cntr_value AS User_Connections FROM master..sysperfinfo as p WHERE p.object_name = 'SQLServer:General Statistics' And p.counter_name = 'User Connections' Thanks anyway. Danny

          1 Reply Last reply
          0
          • D DannyAdler

            Thanks for the reply man. Here's the query result: Invalid object name 'sys.dm_exec_connections'. Using SQL Server 2000... Any idea? Danny

            J Offline
            J Offline
            Justin Perez
            wrote on last edited by
            #5

            Works fine for me. I ran it from code, and I just opened up a SQL Query in SQL Server Management Studio Express and ran it. Would you post the code you are using to execute the query? I'm looking to see if that exists in SQL 2000.

            I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

            D 1 Reply Last reply
            0
            • J Justin Perez

              Works fine for me. I ran it from code, and I just opened up a SQL Query in SQL Server Management Studio Express and ran it. Would you post the code you are using to execute the query? I'm looking to see if that exists in SQL 2000.

              I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

              D Offline
              D Offline
              DannyAdler
              wrote on last edited by
              #6

              No code... Just by running your query on the Enterprise Manager and on the Query Analizer apps. Maybe it's a version thing. Danny

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups