sqlserver查询数据库状态SQL

--连接数    
SELECT count(0) as ConnectCount from sys.dm_exec_connections
--死锁数量    
select cntr_value from sys.dm_os_performance_counters where counter_name = 'Number of Deadlocks/sec' and instance_name = '_Total'
--缓存命中率    
select cntr_value from sys.dm_os_performance_counters where counter_name ='Buffer cache hit ratio'
--SQL发送/select cntr_value from sys.dm_os_performance_counters where counter_name in ('SQL RECEIVEs/sec')
--SQL接受/select cntr_value from sys.dm_os_performance_counters where counter_name in ('SQL RECEIVEs/sec')
--当前可用内存/KB    
SELECT available_physical_memory_kb/1024 as MemoryUse from sys.dm_os_sys_memory
--登录账户信息    
select name, create_date,modify_date from sys.server_principals where type_desc = 'SQL_LOGIN'
--磁盘剩余空间/MB    
Exec master.dbo.xp_fixeddrives

 

posted @ 2023-10-31 10:52  博客YS  阅读(118)  评论(0编辑  收藏  举报