Global Variables in SQL Server - Part3

Posted by in Sql Server category on for Beginner level | Points: 250 | Views : 5865 red flag

Let's learn Global Variables in SQL Server.In my last articles we have already learned about Global Variables and we also learned first 20 global variables. This article is in continuation to the Global Variables in Sql Server Part-2


In this article we are going to learn the global variables in the Sql Server and this article is the continuation  for my previous articles on Global Variables in Sql Server.

List of third 10 Global Variables and their usage are included below:

1)@@PROCID : This is used to get the stored procedure Id of the currently executing procedure

 select @@PROCID as SP_ID
2)@@REMSERVER : This is used to check the name of the database server from which the procedure is run.
select @@REMSERVER as Dbname
3)@@ROWCOUNT : The number of rows affected by the last command. @@rowcount is set to 0 by any command which does not return rows, such as an if statement. With cursors, @@rowcount represents the cumulative number of rows returned from the cursor result set to the client, up to the last fetch request..

select @@ROWCOUNT as effected_rows
4)@@SERVERNAME : The name of the local SQL Server. You must define a server name  with sp_addserver, and then restart SQL Server.
select @@SERVERNAME as server_name
5)@@SERVICENAME : Returns the name of the registry key under which SQL Server is running. @@SERVICENAME returns 'MSSQLSERVER'

select @@SERVICENAME as servericename
6)@@SPID : The server process ID number of the current process.

select @@SPID as ServerProcessID
7)@@TEXTSIZE : The current value of the set text size option, which specifies the maximum length, in bytes, of text or image data to be returned with a select statement. Defaults to 32K.

select @@TEXTSIZE as Text_size
8)@@TIMETICKS : The number of microseconds per tick. The amount of time per tick is machine dependent.
select @@TIMETICKS as MicroSeconds
9) @@TOTAL_ERRORS : The number of errors that have occurred while Sql Server was reading or writing.
select @@TOTAL_ERRORS as errors
10) @@TOTAL_READ : The number of disk reads by SQL Server since it was last started.
select @@TOTAL_READ as Total_read


 In this article we had learned the 10 important global variables which is a continuation  to global variables part 2



Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: vaddilli sarat
Member Level: Bronze
Member Status: Member,MVP
Member Since: 7/30/2012 3:54:23 AM
Country: India
Thanks and Regards V.SaratChand Show difficulties that how difficult you are
I am sarat vaddilli working on the cutting edge technologies like html5,css3, Jquery and MicroSoft technologies like Asp.Net,Asp.Net MVC, SQL Server.

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)