SQL Server常用的全局变量(四)
H_STATUS to control cursor activities in a WHILE loop.
DECLARE Employee_Cursor CURSOR FOR
SELECT LastName, FirstName FROM Northwind.dbo.Employees
OPEN Employee_Cursor
FETCH NEXT FROM Employee_Cursor
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM Employee_Cursor
END
CLOSE Employee_Cursor
DEALLOCATE Employee_Cursor
8.@@IDENTITY --返回上次插入的标记值
Examples
This example inserts a row into a table with an identity column and uses @@IDENTITY to display the identity value used in
the new row.
www.2cto.com
INSERT INTO jobs (job_desc,min_lvl,max_lvl)
VALUES ('Accountant',12,125)
SELECT @@IDENTITY AS 'Identity'
9.@@IDLE --返回SQL Server自上次启动后的空闲时间,结果以CPU时间增量或“时钟周期”表示,并且是所有CPU的累积
Examples
This example shows the number of milliseconds SQL Server was idle between the start time and the current time.
SELECT @@IDLE AS 'Idle ms', GETDATE() AS 'As of'
Here is the result set:
Idle Ms As of
----------------- ---------------------------
277593 1998-04-18 16:41:07.160
10.@@IO_BUSY --返回自从SQL Server最近一次启动以来,Microsoft SQL Server 已经用于执行输入和输出操作的时间。其结果是CPU时间增量(时钟周期),并且是所有CPU的积累值。
Examples
This example shows the number of milliseconds SQL Server has spent performing input/output operations between start time and
the current time.
SELECT @@IO_BUSY AS 'IO ms', GETDATE() AS 'As of'
Here is the result set:
IO ms As of
------------------ -----------------------------
31 1998-04-18 16:49:49.650
11.@@LANGID --返回当前使用的语言的本地语言标识符(ID)
www.2cto.com
Examples
This example sets the language for the current session to Italian, and then uses @@LANGID to return the ID for Italian.
SET LANGUAGE 'Italian'
SELECT @@LANGID AS 'Language ID'
Here is the result set:
Language ID
--------------------
6
12.@@LANGUAGE --返回当前所有语言的名称
Examples
This example returns the language for the current session.
SELECT @@LANGUAGE AS 'Language Name'
Here is the result set:
Language Name
-----------------------------
us_english
13.@@LOCK_TIMEOUT --返回当前会话的当前锁定超时设置(毫秒)
Examples
This example shows the result set when a LOCK_TIMEOUT value is not set.
SELECT @@LOCK_TIMEOUT
Here is the result set:
----------------
-1
This example sets LOCK_TIMEOUT to 1800 milliseconds, and then calls @@LOCK_TIMEOUT.
SET LOCK_TIMEOUT 1800
SELECT @@LOCK_TIMEOUT
Here is the result set:
www.2cto.com
------------------------------
1800
14.@@MAX_CONNECTIONS --返回SQL Server实例允许同时进行的最大用户连接数,返回的数值不一定是当前配置的数值
Examples
This example assumes that SQL Server has not been reconfigured for fewer user connections.
SELECT @@MAX_CONNECTIONS
Here is the result set:
------------------
32767
15.@@MAX_PRECISION --按照服务器当前设置,返回decimal和numeric数据类型所用的精度级别
Examples
SELECT @@MAX_PRECISION
16.@@NESTLEVEL --返回本地服务器上执行的当前存储过程的嵌套级别(初始值为0)
Examples
This example creates two procedures: one that calls the other, and one that displays the @@NESTLEVEL setting of e