Transactional Log Backup Reports
Transactional Log Backup Reports
Transaction_Log_latest_backup_details
-- Query to find latest "Full" as well as "T-Log" backup of all specified Databases
-- Query to find latest "Full" as well as "T-Log" backup of all specified Databases
USE DBA
GO
SELECT msdb.dbo.backupset.server_name
,msdb.dbo.backupset.database_name
,CASE msdb.dbo.backupset.[type] -- Let's decode the main types of backup here
WHEN 'D'
THEN 'Full'
WHEN 'I'
THEN 'Differential'
WHEN 'L'
THEN 'Transaction Log'
WHEN 'F'
THEN 'File or filegroup'
WHEN 'G'
THEN 'Differential file'
WHEN 'P'
THEN 'Partial'
WHEN 'Q'
THEN 'Differential partial'
ELSE msdb.dbo.backupset.[type]
END AS BackupType
go
declare cur1 cursor for SELECT name FROM sys.databases where recovery_model_desc
not like 'SIMPLE'
declare @db15 varchar(90)
open cur1
fetch next from cur1 into @db15
while @@fetch_status=0
begin
open cur
fetch next from cur into @db13,@db12
while @@fetch_status=0
begin
--declare @db14 VARCHAR(90)
end
--update dba..Transaction_Log_latest_backup_details set backup_status='NA' where
backup_status='NULL'
close cur1
deallocate cur1
select * from dba..Transaction_Log_latest_backup_details where BackupType like
'%LOG%' and backup_status ='yes' order by backup_status
declare @var int
set @var=( select count(*) from dba..Transaction_Log_latest_backup_details where
BackupType like '%LOG%' and backup_status ='no' )
if @var >=1
begin
EXEC msdb.dbo.sp_send_dbmail
@profile_name='DBA',
-- replace with your SQL Database Mail Profile
@body = @body,
@body_format ='HTML',
@recipients = '[email protected];[email protected]', -- replace with
your email address
@subject = 'Transaction Log Backups report of fwgongcdb server' ;
end
else if @var < 1
begin
EXEC msdb.dbo.sp_send_dbmail
@profile_name='DBA',
-- replace with your SQL Database Mail Profile
@body = @body,
@body_format ='HTML',
@recipients = '[email protected];[email protected]', -- replace with
your email address
@subject = 'All Transaction Log Backups report of fwgongcdb server' ;
end