Some global variables for SQL Server database

Source: Internet
Author: User
Tags configuration settings

Select App_name () as W--the current session of the application

SELECT @ @IDENTITY--Returns the last inserted identity value Select USER_NAME ()--Returns the user database user name

SELECT @ @CONNECTIONS-Returns the number of connections or attempts to connect since the last SQL startup. Select GETDATE ()--Current time SELECT @ @CPU_BUSY/100--Returns the CPU's working time, in milliseconds, since the last time SQL was started

Use tempdb SELECT @ @DBTS   as w --Returns the value of the current timestamp data type for the current database. This timestamp value is guaranteed to be unique in the database. SELECT @ @IDENTITY as W--Returns the last inserted identity value SELECT @ @IDLE   as w --Returns the time that SQL has been idle since the last startup, in milliseconds select @ @IO_BUSY as W &nb Sp --Returns the time that SQL has been used to perform input and output operations since the last startup, in milliseconds SELECT @ @LANGID as w  --Returns the local language identifier (ID) of the language currently in use. SELECT @ @LANGUAGE as w  --returns the currently used language name SELECT @ @LOCK_TIMEOUT as w -the current lock timeout setting for the current session in milliseconds. SELECT @ @MAX_CONNECTIONS   as w -Returns the maximum number of simultaneous user connections allowed on SQL. The number returned does not have to be the value of the currently configured EXEC sp_configure --Displays the global configuration settings for the current server SELECT @ @MAX_PRECISION as W-returns the precision level used for the decimal and numeric data types, i.e. the service The precision currently set in the service. The default maximum precision is 38. SELECT @ @OPTIONS   as w -returns information about the current SET option. SELECT @ @PACK_RECEIVED As w -returns the number of input packets read from the network since SQL started. SELECT @ @PACK_SENT As w -Returns the number of output packets that have been written to the network since the last boot. SELECT @ @PACKET_ERRORS as w --Returns the number of network packet errors that occurred on the SQL connection since SQL startup. SELECT @ @SERVERNAME as W--Returns the name of the running SQL Server. SELECT @ @SERVICENAME   as W--Returns the registry key name under which SQL is running SELECT @ @TIMETICKS   as W--Returns SQL Server momentmicroseconds SELECT @ @TOTAL_ERRORS as w -Returns the number of disk read/write errors encountered by the SQL Server since it was started. SELECT @ @TOTAL_READ   as w -returns the number of times the SQL Server has read the disk since it started. SELECT @ @TOTAL_WRITE As w -returns the number of times the SQL Server has written to disk since startup. SELECT @ @TRANCOUNT   as w -Returns the number of active transactions for the current connection. SELECT @ @VERSION As w -Returns the date, version, and processor type of the SQL Server installation.

Some global variables for SQL Server database

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.