SQL SERVER – Two Connections Related Global Variables Explained – @@CONNECTIONS and @@MAX_CONNECTIONS

Few days ago, I was searching MSDN and I stumbled upon following two global variables. Following variables are very briefly explained in the BOL. I have taken their definition from BOL and modified BOL example to displayed both the global variable together. The two are @@CONNECTIONS and @@MAX_CONNECTIONS.

SQL SERVER - Two Connections Related Global Variables Explained - @@CONNECTIONS and @@MAX_CONNECTIONS

@@CONNECTIONS
Returns the number of attempted connections, either successful or unsuccessful since SQL Server was last started.

@@MAX_CONNECTIONS
Returns the maximum number of simultaneous user connections allowed on an instance of SQL Server. The number returned is not necessarily the number currently configured.

@@MAX_CONNECTIONS is the maximum number of connections allowed simultaneously to the server. @@CONNECTIONS is incremented with each login attempt, therefore @@CONNECTIONS can be greater than @@MAX_CONNECTIONS.

Example:
SELECT GETDATE() AS 'Currunt Time',
@@CONNECTIONS AS 'Total Logins so far',
@@MAX_CONNECTIONS AS 'Max Connection Simultaneously'

Currunt Time Total Logins so far Max Connection Simultaneously
———————– ——————- —————————–
2007-09-03 17:28:12.013 71 32767

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Function, SQL Scripts, SQL Transactions
Previous Post
SQL SERVER – Introduction and Example for DATEFORMAT Command
Next Post
LEN Versus DATALENGTH: Trailing Spaces and Unicode Bytes

Related Posts

3 Comments. Leave new

  • Can you tell me how to find about the people who accessed my sql server
    This would be very helpful

    Reply
  • I’m writing a batch job using .NET and want to compare a table in our data warehouse with a transactional table, These 2 tables reside on different servers and databases. I am creating a datahandler from .NET and have been told that creating 2 different data connections will not work ???

    Any other ideas or will 2 different connections work with two seperate data adaptors? Any ideas are welcome.

    thanks

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.