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
- SQL Server Global Variable #1 – Introduction of Global Variable
- SQL Server Global Variable #2 – Global Variable 12 of 36 (This post)
- SQL Server Global Variable #3 – Global Variable 24 of 36
- SQL Server Global Variable #4 – Global Variable 36 of 36
- SQL Server Global Variable #5 – Summery of SQL Server Global Variable
In this Article we are going to cover
- CONNECTIONS
- MAX_CONNECTIONS
- CPU_BUSY
- ERROR
- IDENTITY
- IDLE
- IO_BUSY
- LANGID
- LANGUAGE
- .MICROSOFTVERSION
- PACK_RECEIVED
- 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
@@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
@@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
@@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
@@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
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
@@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
@@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
@@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
@@MICROSOFTVERSION
This Global variable return number details of MICROSOFT Version
Help Script
SELECT @@MICROSOFTVERSION AS ' @@MICROSOFT VERSION '
Output
@@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
@@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
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
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.
Yes Justin totally Agree !! Sometimes i find @@Error is like blessing in SQL Server just have to be strong Decoder to understand error !!