Home > Link, Query, SQL > BISQL # 82 – SQL Server Global Variable #4 – Global Variable 36 of 36 – Detailed explanation and Example

BISQL # 82 – SQL Server Global Variable #4 – Global Variable 36 of 36 – Detailed explanation and Example

Hi folks,

Now Today I have decided to complete all list of Global Variable .

So following is links of this series from where I have started explaining 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
  4. SQL Server Global Variable #4 – Global Variable 36 of 36 (This post)
  5. SQL Server Global Variable #5 – Summery of SQL Server Global Variable

In this Article we are going to cover

  1. @@DATEFIRST           
  2. @@DEF_SORTORDER_ID   
  3. @@DEFAULT_LANGID       
  4. @@FETCH_STATUS       
  5. @@LOCK_TIMEOUT       
  6. @@MAX_PRECISION       
  7. @@NESTLEVEL           
  8. @@OPTIONS           
  9. @PROCID               
  10. @@REMSERVER           

    I know two of Global variable I have missed we will complete that too in my last post on Global Variable series

    Now lets understand and Complete the list of remaining Global Variables

    @@DATEFIRST

    This Global variable returns the current value, for a session, of SET DATEFIRST.

    Help Script

    SELECT @@DATEFIRST AS '@@DATEFIRST the 
    current value, for a session'

    Output

    image

    @@DEF_SORTORDER_ID

    This Global variable is to provide deferential sort order ID

    Help Script

    SELECT @@DEF_SORTORDER_ID AS ' @@DEF_SORTORDER_ID provides 
    differential SORTORDER_ID'

    Output

    image

    @@DEFAULT_LANGID

    This Global variable provides Default Login ID.

    Returns 0 if No login ID is Default

    Help Script

    SELECT @@DEFAULT_LANGID                AS ' @@DEFAULT_LANGID'

    Output

    image

    @@FETCH_STATUS

    This Global variable returns the status of the last cursor FETCH statement issued against any cursor currently opened by the connection.

    Help Script

    SELECT @@FETCH_STATUS AS ‘@@FETCH_STATUS gives status of the last cursor’

    Output

    image

    @@LOCK_TIMEOUT

    This Global variable is to SET LOCK_TIMEOUT allows an application to set the maximum time that a statement waits on a blocked resource. When a statement has waited longer than the LOCK_TIMEOUT setting, the blocked statement is automatically canceled, and an error message is returned to the application.

    -1 Represent this time has not been set.

    Help Script

    SELECT @@LOCK_TIMEOUT AS ‘@@LOCK_TIMEOUT to set the maximum time that a statement’

    Output

    image

    @@MAX_PRECISION

    This Global variable the precision level used by decimal and numeric data types as currently set in the server.

    By default, the maximum precision returns 38

    Help Script

    SELECT @@MAX_PRECISION AS '@@MAX_PRECISION precision 
    level used by decimal and numeric data'

    Output

    image

    @@NESTLEVEL

    This Global variable returns returns the nesting level of the current stored procedure execution (initially 0) on the local server.

    When @@NESTLEVEL is executed within a Transact-SQL string, the value returned is 1 +

    the current nesting level.

    When @@NESTLEVEL is executed dynamically by using sp_executesql the value returned is 2 + the current nesting level.

    Help Script

    SELECT @@NESTLEVEL AS '@@NESTLEVEL the nesting 
    level of the current stored procedure'

    Output

    image

    @@OPTIONS

    This Global variable returns information about the current SET options

    Help Script

    SELECT @@OPTIONS AS '@@OPTIONS is information about 
    the current SET options'

    Output

    image

    @@PROCID

    This Global variable returns the object identifier (ID) of the current Transact-SQL module. A Transact-SQL module can be a stored procedure, user-defined function, or trigger. @@PROCID cannot be specified in CLR modules or the in-process data access provider.

    Help Script

    SELECT @@PROCID AS '@@PROCID is the object identifier 
    (ID) of the current Transact-SQL module'

    Output

    image

    @@REMSERVER

    This Global variable enables a stored procedure to check the name of the database server from which the procedure is run

    Help Script

    SELECT @@REMSERVER AS '@@REMSERVER is enables a stored 
    procedure to check the name DB'

    Output

    image

    Note : Last but not least one i.e. summery post on Global Variable i will be completing after having more analysis on Global Variable Section !!  

    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

Advertisements
Categories: Link, 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: