SSMS如何获取事务日志的使用情况?

发布于 2024-08-17 12:26:48 字数 280 浏览 3 评论 0原文

当您右键单击数据库、报告...磁盘使用情况时,我会收到一份报告。因为我的权限有限,所以我只能看到顶部部分,其中显示“事务日志空间使用情况”——仅该数字就对我有用。

但是,后来我收到有关无权运行 DBCC showfilestats 的错误消息,并且我也绝对无权访问 sys.dm_os_performance_counters 或 DBCC SQLPERF('logspace')。

如果我能得到那个最高的数字,那就很有用了。不幸的是,我当然无法运行探查器,所以我不知道它发出什么命令或查询来获取该数据......

When you right-click on database, Reports...Disk Usage, I get a report. Because I have limited permissions, I only get the top portion, which shows "Transaction Log Space Usage" - that number alone could be useful to me.

However, later I get error messages about not having permissions to run DBCC showfilestats, and I also definitely don't have access to sys.dm_os_performance_counters or DBCC SQLPERF('logspace').

If I can just get that top number, that would be useful. Unfortunately, I cannot run the profiler, of course, so I have no idea what command or query it's issuing to even get that data...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗地喜欢 2024-08-24 12:26:48

我自己的 SSMS 磁盘使用情况报告的探查器捕获显示 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''

Profiler capture of my own SSMS Disk Usage report shows 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''
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文