SQLServer system variable

 

 

1, @@ IDENTITY
return the last inserted identity value. This variable is useful when you insert a row, to simultaneously obtain an ID of the row (labeled column), you can use the IDENTITY @@
Example: The following example inserts a row into the table with the identified column, and washed with @@ iDENTITY display identification value used in the new row.
Jobs the INTO the INSERT (the job_desc, min_lvl, max_lvl) the VALUES ( 'the Accountant', 12,125)
the SELECT @@ the IDENTITY the AS 'the Identity'

2, @@ ROWCOUNT
returns the number of rows affected by the last statement.
Example: The following example executes an UPDATE statement and use @@ ROWCOUNT to detect if there are changes in the line.
The authors the SET = the au_lname the UPDATE 'Jones' = the au_id the WHERE '999-888-7777'
the IF @@ ROWCOUNT = 0
Print 'Warning: No rows were Updated'

3, @@ CONNECTIONS
returns the number of its Microsoft SQL Server connections or attempted connections since the last start.
Example: The following example shows a number of times until the present date and time attempting to log on.
SELECT GETDATE () AS 'Date and Time', @@ CONNECTIONS AS 'Login Attempts'

4, @@ CPU_BUSY
return since the last start since Microsoft SQL Server CPU working time, in milliseconds (based on the system timer resolution).
Example: The following example shows the current date and time until the SQL Server CPU activity
SELECT @@ CPU_BUSY AS 'CPU ms' , GETDATE () AS 'As of'

5, @@ DATEFIRST
returns the current value of the parameter SET DATEFIRST, SET DATEFIRST parameter indicates the predetermined day of the week: Monday, corresponding to 1, 2 corresponding to Tuesday, and so on, with the corresponding 7 Sunday.
Example: The following example is set to 5 (Friday) day of the week, and assuming the same day is Saturday. SELECT statement returns DATEFIRST value and the date of the first few days of this week.
DATEFIRST. 5 the SET
the SELECT @@ DATEFIRST the AS '1st Day', DATEPART (DW, GETDATE ()) the AS 'Today'

6, @@ IO_BUSY
return Microsoft SQL Server since the last boot time for performing input and output operations of milliseconds (based on the resolution of the system timer).
Example: The following example shows the SQL Server from the start to the currently used to perform input / output operations milliseconds.
SELECT @@ IO_BUSY AS 'IO ms' , GETDATE () AS 'As of'

7, @@ LANGID
returns the current local language used by the language identifier (ID).
Example: The following example is set to the current session Italian language (Italian), and then returns the Italian ID with @@ LANGID.
The LANGUAGE the SET 'Italian'
the SELECT @@ LANGID the AS 'Language ID'

8, @@ LANGUAGE
returns the language name currently in use.
Example: The following example returns the language of the current session.
SELECT @@ LANGUAGE AS 'Language Name'

9, @@ MAX_CONNECTIONS
returns the maximum number of Microsoft SQL Server allows the simultaneous user connections. Returns the value of the current need not be configured.
Example: The following example assumes SQL Server Not less reconfigured user connections.
SELECT @@ MAX_CONNECTIONS

10, @@ PACK_RECEIVED
return the number of packets enter the Microsoft SQL Server since it was last started reading from the network.
Examples
SELECT @@ PACK_RECEIVED

11, @@ PACK_SENT
return to Microsoft SQL Server since the last start number written to the output data packets on the network.
Examples
SELECT @@ PACK_SENT

12, @@ PACKET_ERRORS
return since SQL Server last started, the number of connections on the network packet errors occur in the Microsoft SQL Server.
Examples
SELECT @@ PACKET_ERRORS

13, @@ SERVERNAME
returns the name of the local server running Microsoft SQL Server's.
Examples
SELECT @@ SERVERNAME

14, @@ SERVICENAME
returns registry key name under which Microsoft SQL Server is running. Examples If the current default instance, @@ SERVICENAME returns the MSSQLServer; if the current instance is a named instance, the function returns the name of the instance.
Examples
SELECT @@ SERVICENAME

15, @@ SPID
back to the server process identifier (ID) of the current user process.
Example: The following example returns the current process user process ID, login name and user name.
SELECT @@ SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name'

16, @@ TIMETICKS
number of microseconds of a scale.
Examples
SELECT @@ TIMETICKS

17, @@ TOTAL_ERRORS
return disk read Microsoft SQL Server since the last boot, encountered / write errors.
Example: The following example shows the number of errors SQL Server up to the current date and time of the encounter.
SELECT @@ TOTAL_ERRORS AS 'Errors', GETDATE () AS 'As of'

18, @@ TOTAL_WRITE
return to Microsoft SQL Server since it was last written to disk boot times.
Example: The following example shows the total number of read and write to the disk until the current date and time.
SELECT @@ TOTAL_READ AS 'Reads', @@ TOTAL_WRITE AS 'Writes', GETDATE () AS 'As of'

19, @@ VERSION
return date version of Microsoft SQL Server and processor type currently installed.
Example: The following example returns the date, version, and type of processor currently installed.
SELECT @@ VERSION

20, @@ TOTAL_READ
return to Microsoft SQL Server since it was last started reading the disk (not a read cache) number of times.
Example: The following example shows the total number of write up to the current date and time of the disk.
SELECT @@ TOTAL_READ AS 'Reads', @@ TOTAL_WRITE AS 'Writes', GETDATE () AS 'As of'

1, @@ IDENTITY
return the last inserted identity value. This variable is useful when you insert a row, to simultaneously obtain an ID of the row (labeled column), you can use the IDENTITY @@
Example: The following example inserts a row into the table with the identified column, and washed with @@ iDENTITY display identification value used in the new row.
Jobs the INTO the INSERT (the job_desc, min_lvl, max_lvl) the VALUES ( 'the Accountant', 12,125)
the SELECT @@ the IDENTITY the AS 'the Identity'

2, @@ ROWCOUNT
returns the number of rows affected by the last statement.
Example: The following example executes an UPDATE statement and use @@ ROWCOUNT to detect if there are changes in the line.
The authors the SET = the au_lname the UPDATE 'Jones' = the au_id the WHERE '999-888-7777'
the IF @@ ROWCOUNT = 0
Print 'Warning: No rows were Updated'

3, @@ CONNECTIONS
returns the number of its Microsoft SQL Server connections or attempted connections since the last start.
Example: The following example shows a number of times until the present date and time attempting to log on.
SELECT GETDATE () AS 'Date and Time', @@ CONNECTIONS AS 'Login Attempts'

4, @@ CPU_BUSY
return since the last start since Microsoft SQL Server CPU working time, in milliseconds (based on the system timer resolution).
Example: The following example shows the current date and time until the SQL Server CPU activity
SELECT @@ CPU_BUSY AS 'CPU ms' , GETDATE () AS 'As of'

5, @@ DATEFIRST
returns the current value of the parameter SET DATEFIRST, SET DATEFIRST parameter indicates the predetermined day of the week: Monday, corresponding to 1, 2 corresponding to Tuesday, and so on, with the corresponding 7 Sunday.
Example: The following example is set to 5 (Friday) day of the week, and assuming the same day is Saturday. SELECT statement returns DATEFIRST value and the date of the first few days of this week.
DATEFIRST. 5 the SET
the SELECT @@ DATEFIRST the AS '1st Day', DATEPART (DW, GETDATE ()) the AS 'Today'

6, @@ IO_BUSY
return Microsoft SQL Server since the last boot time for performing input and output operations of milliseconds (based on the resolution of the system timer).
Example: The following example shows the SQL Server from the start to the currently used to perform input / output operations milliseconds.
SELECT @@ IO_BUSY AS 'IO ms' , GETDATE () AS 'As of'

7, @@ LANGID
returns the current local language used by the language identifier (ID).
Example: The following example is set to the current session Italian language (Italian), and then returns the Italian ID with @@ LANGID.
The LANGUAGE the SET 'Italian'
the SELECT @@ LANGID the AS 'Language ID'

8, @@ LANGUAGE
returns the language name currently in use.
Example: The following example returns the language of the current session.
SELECT @@ LANGUAGE AS 'Language Name'

9, @@ MAX_CONNECTIONS
returns the maximum number of Microsoft SQL Server allows the simultaneous user connections. Returns the value of the current need not be configured.
Example: The following example assumes SQL Server Not less reconfigured user connections.
SELECT @@ MAX_CONNECTIONS

10, @@ PACK_RECEIVED
return the number of packets enter the Microsoft SQL Server since it was last started reading from the network.
Examples
SELECT @@ PACK_RECEIVED

11, @@ PACK_SENT
return to Microsoft SQL Server since the last start number written to the output data packets on the network.
Examples
SELECT @@ PACK_SENT

12, @@ PACKET_ERRORS
return since SQL Server last started, the number of connections on the network packet errors occur in the Microsoft SQL Server.
Examples
SELECT @@ PACKET_ERRORS

13, @@ SERVERNAME
returns the name of the local server running Microsoft SQL Server's.
Examples
SELECT @@ SERVERNAME

14, @@ SERVICENAME
returns registry key name under which Microsoft SQL Server is running. Examples If the current default instance, @@ SERVICENAME returns the MSSQLServer; if the current instance is a named instance, the function returns the name of the instance.
Examples
SELECT @@ SERVICENAME

15, @@ SPID
back to the server process identifier (ID) of the current user process.
Example: The following example returns the current process user process ID, login name and user name.
SELECT @@ SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name'

16, @@ TIMETICKS
number of microseconds of a scale.
Examples
SELECT @@ TIMETICKS

17, @@ TOTAL_ERRORS
return disk read Microsoft SQL Server since the last boot, encountered / write errors.
Example: The following example shows the number of errors SQL Server up to the current date and time of the encounter.
SELECT @@ TOTAL_ERRORS AS 'Errors', GETDATE () AS 'As of'

18, @@ TOTAL_WRITE
return to Microsoft SQL Server since it was last written to disk boot times.
Example: The following example shows the total number of read and write to the disk until the current date and time.
SELECT @@ TOTAL_READ AS 'Reads', @@ TOTAL_WRITE AS 'Writes', GETDATE () AS 'As of'

19, @@ VERSION
return date version of Microsoft SQL Server and processor type currently installed.
Example: The following example returns the date, version, and type of processor currently installed.
SELECT @@ VERSION

20, @@ TOTAL_READ
return to Microsoft SQL Server since it was last started reading the disk (not a read cache) number of times.
Example: The following example shows the total number of write up to the current date and time of the disk.
SELECT @@ TOTAL_READ AS 'Reads', @@ TOTAL_WRITE AS 'Writes', GETDATE () AS 'As of'

Guess you like

Origin www.cnblogs.com/wfy680/p/11972183.html