Introduction to common global variables in SQL Server

Source: Internet
Author: User

InSQL ServerMedium,Global VariablesIs a special type of variable, the server will maintain the value of these variables. Global variables start with @ and do not need to be declared. They are system-defined functions. The following table lists some common global variables in SQL Server.

Global variable name

Description

@ Connections

Returns the number of connections that SQL Server has attempted since its last startup.

@ Cpu_busy

Returns the time that SQL server has been started since the last time.

@ Cursor_rows

Returns the number of currently limited rows in the previous cursor opened on the connection,

Determine the number of rows that the cursor matches when it is called.

@ Datefirst

Returns the current set datefirst value for the session. Set datefirst indicates the specified

The first day of each week.

@ Dbts

Returns the value of the current timestamp Data Type of the current database,

The timestamp value must be unique in the database.

@ Error

Returns the error code of the last executed Transact-SQL statement,

If the execution of the previous Transact-SQL statement is correct, 0 is returned.

@ Fetch_status

Returns the last cursor fetch sent for any cursor currently opened.

Statement status.

@ Identity

Returns the id value inserted last time.

@ Idle

Returns the idle time of SQL Server since it was last started. The result is the CPU time.

Incremental or "clock cycle" indicates the accumulation of all CPUs.

@ Io_busy

Returns the result of Microsoft SQL Server

The time when the input and output operations are performed. The result is the CPU time increment.

(Clock cycle), and is the cumulative value of all CPUs

@ Langid

Returns the local language identifier (ID) of the currently used language ).

@ Language

Returns the name of the current language.

@ Lock_timeout:

Returns the current lock timeout value of the current session in milliseconds ).

@ Max_connections

Returns the maximum number of concurrent user connections allowed by the SQL server instance.

The returned value is not necessarily the currently configured value.

@ Max_precision

Returns the decimal and numeric data types according to the current settings on the server.

The precision level used.

@ Nestlevel

Returns the nesting level of the current Stored Procedure executed on the local server (Initial Value: 0 ).

@ Options

Returns information about the current set option.

@ Pack_received

Returns the number of input data packets read from the Network since SQL Server was last started.

@ Pack_sent

Returns the number of output data packets written to the network after SQL Server is last started.

@ Packet_errors

Returns the network that has occurred on the SQL server connection since SQL Server was last started.

Number of packet errors.

@ Procid

Returns the object identifier (ID) of the current Transact-SQL module ). Transact-SQL

A module can be a stored procedure, user-defined function, or trigger.

@ Remserver

Return the name displayed in the logon record of the Remote SQL Server database server.

@ Rowcount

Returns the number of rows affected by the previous statement.

@ Servername

Returns the name of the local server that runs SQL Server.

@ Servicename

Returns the name of the registry that is running under SQL Server. If the current instance is

For the default instance, @ servicename returns MSSQLServer.

@ Spid

Returns the session ID of the current user process.

@ Textsize

Returns the current value of the textsize option in the Set statement.

@ Timeticks

Returns the number of microseconds in each clock cycle.

@ Total_errors

Returns the number of disk write errors that SQL Server has encountered since its last startup.

@ Total_read

Returns the number of times that SQL Server reads a disk (not a high-speed cache read) since it was last started.

@ Total_write

Returns the number of disk writes performed by SQL Server since it was last started.

@ Trancount

Returns the number of active transactions for the current connection.

@@ version

returns the version, processor architecture, and generation date of the current SQL Server Installation.

and operations system.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.