mssql sqlserver sql引擎系统全局变量简介说明


摘要:
下文分享sql引擎中的系统全局变量简介,如下所示:
实验环境:sql server 2008 R2


SELECT @@SERVERNAME as [当前sql服务器名称] –返回运行SQL服务器名称。
SELECT @@SERVICENAME as [当前sql服务器注册名称–注册表上]
SELECT @@PACK_SENT as [自上次启动后发送至网络数据包数目]
SELECT @@PACKET_ERRORS as [自上次启动后发送至网络数据包错误包数目]
SELECT @@TIMETICKS as [返回服务器当前微秒数]
SELECT @@TOTAL_ERRORS AS [自上次启动后磁盘读写的错误数]
SELECT @@TOTAL_READ as [自上次启动后磁盘读的次数]
SELECT @@TOTAL_WRITE as [自上次启动后磁盘写的次数]
SELECT @@TRANCOUNT as [当前连接的活动事务数]
SELECT @@VERSION as [sql引擎安装日期 版本 处理器型号]
select APP_NAME ( ) as [当前会话所对应的应用程序]
select @@ERROR as [最后一句sql执行所产生的错误码]
select @@IDENTITY as [最后插入的标识列]
SELECT USER_NAME() as [当前会话所对应的用户数据库名称]
SELECT @@CONNECTIONS [自上次启动后被连接和试图连接的次数之和]
SELECT GETDATE() as [sql引擎当前时间 ]
SELECT @@CPU_BUSY [自上次启动后cpu的工作时间毫秒]
SELECT @@DBTS as [当前数据库的timestamp值]
SELECT @@IDLE as [自上次启动后cpu的空闲时间毫秒]
SELECT @@IO_BUSY AS [自上次启动后IO的工作时间毫秒]
SELECT @@LANGID AS [当前数据库引擎语言Id]
SELECT @@LANGUAGE AS [当前数据库引擎所使用的语言]
SELECT @@LOCK_TIMEOUT as [会话超时时间设定值-毫秒]
SELECT @@MAX_PRECISION as [当前decimal numeric的数据类型精度级别]
select @@OPTIONS as [当前sql引擎set值信息 ]
SELECT @@PACK_RECEIVED as [自上次启动后网络上接收数据包的个数]