Home > Query, SQL > BISQL # 81 – SQL Server Global Variable #3 – Global Variable 24 of 36 – Detailed explanation and Example

BISQL # 81 – SQL Server Global Variable #3 – Global Variable 24 of 36 – Detailed explanation and Example

Hello friends,

Lets continue from my last post in series of Global variable

  1. SQL Server Global Variable #1 – Introduction of Global Variable
  2. SQL Server Global Variable #2 – Global Variable 12 of 36
  3. SQL Server Global Variable #3 – Global Variable 24 of 36 (This post)
  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. @@PACKET_ERRORS    
  2. @@ROWCOUNT         
  3. @@SERVERNAME    
  4. @@SPID            
  5. @@TEXTSIZE        
  6. @@TIMETICKS        
  7. @@TOTAL_ERRORS    
  8. @@TOTAL_READ       
  9. @@TOTAL_WRITE   
  10. @@TRANCOUNT        
  11. @@VERSION         
  12. @@CURSOR_ROWS   

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

Lets see next 12 Global Variable …

@@PACKET_ERRORS

This Global variable returns the number of network packet errors that have occurred on SQL Server connections since SQL Server was last started.

Help Script

SELECT @@PACKET_ERRORS AS '@@PACKET_ERRORS 
is the number of network packet errors'

Output

image_thumb[29]

@@ROWCOUNT  

This Global variable returns the number of rows affected by the last statement.

Help Script

SELECT @@ROWCOUNT AS '@@ROWCOUNT is the number of 
rows affected by the last statement'

Output

image

@@SERVERNAME

This Global variable returns the name of the local server that is running SQL Server.

Help Script

SELECT @@SERVERNAME AS '@@SERVERNAME is name
 of the local server'

Output

image

@@SPID 

This Global variable returns the session ID of the current user process

Help Script

SELECT @@SPID AS '@@SPID identify the current
 user process in the output'

Output

image

@@TEXTSIZE 

This Global variable returns the current value of the TEXTSIZE option

Help Script

SELECT @@TEXTSIZE AS '@@TEXTSIZE is current 
value of the TEXTSIZE option'

Output

image

@@TIMETICKS 

This Global variable returns the number of microseconds per tick.

The amount of time per tick is computer-dependent.

Each tick on the operating system is 31.25 milliseconds, or one thirty-second of a second

Help Script

SELECT @@TIMETICKS AS '@@TIMETICKS is the 
number of microseconds per tick'

Output

image

@@TOTAL_ERRORS 

This Global variable returns the number of disk write errors encountered by SQL Server since SQL Server last started.

Help Script

SELECT @@TOTAL_ERRORS AS '@@TOTAL_ERRORS is the 
number of disk write errors'

Output

image

@@TOTAL_READ

This Global variable returns the number of disk reads, not cache reads, by SQL Server since SQL Server was last started.

Help Script

SELECT  @@TOTAL_READ AS '@@TOTAL_READ is the 
number of disk reads'

Output

image

@@SERVICENAME  

This Global variable returns the name of the registry key under which SQL Server is running

Help Script

SELECT @@SERVICENAME AS '@@SERVICENAME Gives 
name of the registry key'

Output

image

@@TOTAL_WRITE 

This Global variable returns the number of disk writes by SQL Server since SQL Server was last started

Help Script

SELECT @@TOTAL_WRITE AS '@@TOTAL_WRITE is 
the number of disk writes'

Output

image

@@TRANCOUNT 

This Global variable returns the number of active transactions for the current connection.

Help Script

SELECT @@TRANCOUNT AS '@@TRANCOUNT is the number of active 
transactions for the current connection'

Output

image

@@VERSION  

This Global variable returns version, processor architecture, build date, and operating system for the current installation of SQL Server.

Help Script

SELECT @@VERSION AS '@@VERSION is Version details'

Output

image

@@CURSOR_ROWS

This Global variable returns the number of qualifying rows currently in the last cursor opened on the connection

Help Script

SELECT @@CURSOR_ROWS AS '@@CURSOR_ROWS is the 
number of qualifying rows currently'

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. No comments yet.
  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: