Useful sqlserver global variables

Source: Internet
Author: User
Tags configuration settings
Select app_name () as appname -- Name of the application in the current session.
Select @ error -- return the error code (integer) of the last executed Transact-SQL statement ).
Select @ identity -- return the last inserted id value.
Select user_name () -- returns the user database username.
Select @ connections -- returns the number of connections or attempts since the last SQL startup.
Select getdate () -- current time.
Select @ cpu_busy/100 -- returns the CPU time (in milliseconds) since the last SQL statement was started ).
Use tempdb select @ dbts as timestamp -- returns the current timestamp data type value for the current database. This timestamp value must be unique in the database.
Select @ idle as temp -- returns the idle time (in milliseconds) of the SQL statement since it was last started ).
Select @ io_busy as w -- returns the time (in milliseconds) that the SQL statement was used to perform input and output operations since the last time it was started ).
Select @ langid as w -- returns the local language identifier (ID) of the current language ).
Select @ language as w -- returns the current language name.
Select @ lock_timeout as w -- set the current lock timeout for the current session (unit: milliseconds ).
Select @ max_connections as w -- returns the maximum number of simultaneous user connections allowed on SQL. The number returned does not need to be the currently configured value.
Exec sp_configure -- display the global configuration settings of the current server.
Select @ max_precision as w -- return the precision level used by the decimal and numeric data types, that is, the currently set precision on this server. 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 data packets read from the network after SQL is started.
Select @ pack_sent as w -- return the number of output data packets written to the network by sq since the last start.
Select @ packet_errors as w -- returns the number of network packet errors that have occurred on the SQL connection since the SQL startup.
Select @ servername as w -- return the name of the running SQL Server.
Select @ servicename as w -- return the registry key name that is running under the SQL statement.
Select @ timeticks as w -- returns the number of microseconds at a scale of the SQL Server.
Select @ total_errors as w -- returns the number of disk read/write errors that the SQL Server encounters after it is started.
Select @ total_read as w -- returns the number of times the SQL Server reads the disk after it is started.
Select @ total_write as w -- return the number of times the SQL server writes data to the disk after it is started.
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. # Database Technology

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.