未加星标

T-SQL Tuesday: Connect item Last Log Backup Time

字体大小 | |
[数据库(mssql) 所属分类 数据库(mssql) | 发布者 店小二03 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

T-SQL Tuesday: Connect item   Last Log Backup Time

T-SQL Tuesday is a blog party started by Adam Machanic ( b/ t ) over five years ago. The first Tuesday of each month a blogger hosts the party and suggests a topic. Then anyone who is interested blogs on that topic on the second Tuesday. It can be a lot of fun and quite a challenge to blog on a topic you didn’t pick.

This month’s topic is presented by Brent Ozar( b / t ), who has challenged us tofind our favorite Bug report or feature request on MS Connect and write about it.

I don’t have a lot of experience with Connect, other than landing there from Google a few times while researching stuff. I’m pretty sure I’ve never filed a report or request. So, I just went looking through the latest requests and found one concerning “ Check the time for the latest log backup ” from none other than Ola Hallengren ( w ).

Ola’s feature request is:

I would like to ask for a way to check when the last log backup was performed.

His reasoning for the request:

This enables you to have a backup strategy with more frequent transaction log backups when there is a lot of activity in the database.

And his proposed solution:

Add a new column to sys.dm_db_log_space_usage or sys.database_recovery_status called LastLogBackupTime.

I LOVE this idea…back up the T-log more frequently during busy times, less often during off hours. At my current client, there is almost nothing happening outside of a 12 hour workday window, so this would be perfect here.

Now, I am possiblymisunderstanding Ola’srequest or the intent…and that’s ok. This query from the msdb..backupset table already contains this info via a relatively short amount of code:

Use MSDB
go
Select
[Database_Name] as [Database Name],
DB_id([database_name]) as [DB ID],
Max(backup_Start_date) as [Last log backup]
From
msdb..backupset bs
Where 1=1
and db_id([database_name]) is not null
and type = 'L'
Group by
[database_name]
Order By
Max(backup_start_date)

This returns a result set of:


T-SQL Tuesday: Connect item   Last Log Backup Time

So…the info requested can already be gathered. There may very well be other ways to do this, or querying this table may be deprecated. It seems that Ola is looking for a cleaner solution by adding to an existing System View in MSDB in order to more easily tie it to log size.

I do know and respect Ola’s maintenance scripts, so I have posted a comment on the Connect item asking for some clarification. And, I have voted it up. I encourage YOU to do the same….as this simple request is probably going to wind up in his scripts

Thanks for reading!

Kevin3NF

本文数据库(mssql)相关术语:熊片数据库 mssql数据库 oracle数据库 pubmed数据库 access数据库 万方数据库

主题: SQL
分页:12
转载请注明
本文标题:T-SQL Tuesday: Connect item Last Log Backup Time
本站链接:http://www.codesec.net/view/523341.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(mssql) | 评论(0) | 阅读(49)