Common global variables in SQL

Source: Internet
Author: User
Tags configuration settings

Select App_name () as W--Application for current session SELECT @ @IDENTITY--Returns the last inserted identity value Select USER_NAME ()--Returns the user database user name SELECT @ @CONNECTION S--Returns the number of connections or attempts to connect since the last SQL startup.  Select GETDATE ()--Current time SELECT @ @CPU_BUSY/100--Returns the working time of the CPU since the last SQL startup, in milliseconds use tempdb SELECT @ @DBTS as W--Returns the current The value of the timestamp data type. 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--returns SQL from the last boot The time of the input and output operations, 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, that is, the current Sets the precision. The default maximum precision is 38. SELECT @ @OPTIONS as W-returns information for 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 startup. 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--the number of microseconds to return a SQL Server moment select @ @TOTAL_ERRORS as W--return 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.

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.