TSQL--SQL SERVER 經常使用系統變量

----------全局變量
select @@version as '版本';---------------------------返回當前數據庫的版本信息
 
select APP_NAME ( ) as '當前會話應用程序';------------返回當前會話的應用程序信息數據庫

select @@ERROR as '錯誤ID';---------------------------返回上一次TSQL的錯誤ID,若是正常執行了查詢,error爲0,出錯時error必定大於0,可用於事務中服務器

select @@IDENTITY as '標示符';------------------------返回最後一次的標識符,如先執行了server

select user_name()as '當前用戶';----------------------返回當前用戶進程

select @@connections as '鏈接次數';-------------------返回自上次SQL啓動以來鏈接或試圖鏈接的次數。事務

select getdate() as '當前時間';-----------------------返回當前時間get

select @@cpu_busy/100 as 'CPU工做時間';---------------返回自上次啓動SQL 以來 CPU 的工做時間,單位爲毫秒it

select @@language as '語言';--------------------------返回當前語言io

select @@lock_timeout as '超時鎖定設置';--------------返回超時鎖定設置的值變量

select @@max_connections as '容許最大鏈接數';---------返回容許最大鏈接數配置

exec sp_configure;------------------------------------系統存儲過程,顯示默認配置

select @@options as '選項';---------------------------返回set選項值

select @@servername as '服務器名稱';------------------返回當前數據庫服務器名稱

select @@servicename as '註冊名稱' ;------------------返回註冊的SQL服務名稱

select @@total_errors as '錯誤總數';------------------返回至啓動以來的錯誤總數

select @@total_read as '讀取總數';--------------------返回自啓動以來的讀取總數

select @@total_write as '寫入總數';-------------------返回自啓動以來的寫入總數

select @@spid as '當前進程pid';-----------------------返回當前會話用戶pid

相關文章
相關標籤/搜索