SQL Server pool size
-
Hi all, Is there a C# way for retrieving the number of currently opened sql-connections? Thanks in advance, Danny
-
Hi all, Is there a C# way for retrieving the number of currently opened sql-connections? Thanks in advance, Danny
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
-
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
Thanks for the reply man. Here's the query result: Invalid object name 'sys.dm_exec_connections'. Using SQL Server 2000... Any idea? Danny
-
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
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
-
Thanks for the reply man. Here's the query result: Invalid object name 'sys.dm_exec_connections'. Using SQL Server 2000... Any idea? Danny
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
-
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
No code... Just by running your query on the Enterprise Manager and on the Query Analizer apps. Maybe it's a version thing. Danny