当您右键单击数据库,报告...磁盘使用情况时,我会收到报告。因为我的权限有限,所以我只得到顶部,显示“事务日志空间使用” - 这个数字本身对我有用。
但是,稍后我收到有关无权运行DBCC showfilestats的错误消息,而且我也无法访问sys.dm_os_performance_counters或DBCC SQLPERF('logspace')。
如果我能得到那个最高号码,那将是有用的。不幸的是,我无法运行探查器,所以我不知道它发出什么命令或查询来获取数据...
答案 0 :(得分:1)
我自己的SSMS磁盘使用情况报告的Profiler捕获显示DBCC SQLPERF(LOGSPACE)
:
exec sp_executesql @stmt=N'begin try
declare @tran_log_space_usage table(
database_name sysname
, log_size_mb float
, log_space_used float
, status int
);
insert into @tran_log_space_usage
exec(''DBCC SQLPERF ( LOGSPACE )'') ;
select 1 as l1
, 1 as l2
, log_size_mb as LogSizeMB
, cast( convert(float,log_space_used) as decimal(10,1)) as SpaceUsage
, ''Used'' as UsageType
from @tran_log_space_usage
where database_name = DB_NAME()
UNION
select 1 as l1
, 1 as l2
, log_size_mb
, cast(convert(float,(100-log_space_used)) as decimal(10,1)) as SpaceUsage
, ''Unused'' as UsageType
from @tran_log_space_usage
where database_name = DB_NAME();
end try
begin catch
select -100 as l1
, ERROR_NUMBER() as l2
, ERROR_SEVERITY() as LogSizeMB
, ERROR_STATE() as SpaceUsage
, ERROR_MESSAGE() as UsageType
end catch',@params=N''