Home > Query, SQL > BISQL # 80 – SQL Server Global Variable #2 – Global Variable 12 of 36 – Detailed explanation and Examples

BISQL # 80 – SQL Server Global Variable #2 – Global Variable 12 of 36 – Detailed explanation and Examples

Hi Folks,

Lets continue from my last post on Global variable

  1. SQL Server Global Variable #1 – Introduction of Global Variable
  2. SQL Server Global Variable #2 – Global Variable 12 of 36 (This post)
  3. SQL Server Global Variable #3 – Global Variable 24 of 36
  4. SQL Server Global Variable #4 – Global Variable 36 of 36
  5. SQL Server Global Variable #5 – Summery of SQL Server Global Variable

In this Article we are going to cover

  1. CONNECTIONS
  2. MAX_CONNECTIONS
  3. CPU_BUSY
  4. ERROR
  5. IDENTITY
  6. IDLE
  7. IO_BUSY
  8. LANGID
  9. LANGUAGE
  10. .MICROSOFTVERSION
  11. PACK_RECEIVED
  12. PACK_SENT

Global variable are most used variable in SQL Server as these are One of the important aspect and needed at various stages of development.

Now lets look into above Global variable 

@@CONNECTIONS

This Global variable is incremented with each login attempt, therefore @@CONNECTIONS can be greater than @@MAX_CONNECTIONS SQL Server was last started

Help Script

SELECT @@CONNECTIONS 
AS '@@CONNECTIONS is incremented with each login attempt 
and is The number of attempted connections'

Output

image

@@MAX_CONNECTIONS

This Global variable is used for maximum number of connections allowed simultaneously to the serve

Help Script

SELECT @@MAX_CONNECTIONS 
AS '@@MAX_CONNECTIONS Is the maximum number 
of connections allowed simultaneously'

Output

image

@@CPU_BUSY

This Global variable will Returns the time that SQL Server has spent working since it was last started

Result is in CPU time increments, or "ticks," and is cumulative for all CPUs,so it may exceed the actual elapsed time.

Help Script

SELECT @@CPU_BUSY AS '@@CPU_BUSY is in CPU time increments,
 or "ticks," and is cumulative for all CPUs'

Output

image

@@ERROR  

This Global variable returns the error number for the last Transact-SQL statement executed

Help Script

SELECT @@ERROR AS '@@ERROR is the error number'

Output

image

@@IDENTITY  

This Global variable is a system function that returns the last-inserted identity value

Help Script

SELECT @@IDENTITY AS '@@IDENTITY is the last-inserted identity value'

Output

image

as no identity operation on SQL Server.

@@IDLE 

This Global variable returns the time that SQL Server has been idle since it was last started.

The result is in CPU time increments, or "ticks," and is cumulative for all CPUs,so it may exceed the actual elapsed time

Help Script

SELECT @@IDLE AS '@@IDLE is the time that SQL Server has 
been idle since it was last started'

Output

image

@@IO_BUSY  

This Global variable returns the time that SQL Server has spent performing input and output operations

Since SQL Server was last started. The result is in CPU time increments ("ticks"),and is cumulative for all CPUs, so it may exceed the actual elapsed time.

Help Script

SELECT @@IO_BUSY AS '@@IO_BUSY is 
has spent performing input and output operations'

Output

image

@@LANGID  

This Global variable returns the local language identifier which (ID) of the language that is currently being used,

Help Script

SELECT @@LANGID AS '@@LANGID is the local language identifier '

Output

image

@@LANGUAGE 

This Global variable returns the name of the language currently being used

Help Script

SELECT @@LANGUAGE AS 'LANGUAGE Used in this SQL Server'

Output

image

@@MICROSOFTVERSION  

This Global variable return number details of MICROSOFT Version

Help Script

SELECT @@MICROSOFTVERSION     AS ' @@MICROSOFT VERSION '

Output

image

@@PACK_RECEIVED

This Global variable returns the number of input packets read from the network by SQL Server since it was last started.

Help Script

SELECT @@PACK_RECEIVED AS '@@PACK_RECEIVED is number of 
input packets read from the network'

Output

image

@@PACK_SENT  

This Global variable returns the number of output packets written to the network by SQL Server since it was last started.

Help Script

SELECT @@PACK_SENT AS '@@PACK_SENT is number of 
output packets written to the network'

Output

image

Hope this Helps !!!!

Thanks for visiting my blog !!

Hope you will like this post on  Details of 12 Global Variable and explanation with example.

If you really like reading my blog and understood at lest few thing then please don’t forget to subscribe my blog .

If you wan daily link and analysis or interesting link go to following website which will give @ your inbox please subscribe our following link resource blog

Where todays links are

Link Resource Website

Advertisement
Categories: Query, SQL
  1. December 29, 2011 at 1:36 am

    Nice review of SQL Server global variables. I personally find @@ERROR and @@IDENTITY to be very useful and use them quite a bit in day-to-day code.

  2. December 29, 2011 at 10:31 am

    Yes Justin totally Agree !! Sometimes i find @@Error is like blessing in SQL Server just have to be strong Decoder to understand error !!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: