Skip to content

Commit 9efb841

Browse files
authored
Merge pull request #3962 from BrentOzarULTD/sp_BlitzBackups-StartTime-CheckId-7-12
sp_BlitzBackups: use @starttime for CheckId 7 and 12
2 parents 69ffdd0 + b88100f commit 9efb841

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

sp_BlitzBackups.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -975,18 +975,18 @@ RAISERROR('Rules analysis starting', 0, 1) WITH NOWAIT;
975975
100 AS [Priority],
976976
b.database_name AS [Database Name],
977977
''No CHECKSUMS'' AS [Finding],
978-
''The database '' + QUOTENAME(b.database_name) + '' has been backed up '' + CONVERT(VARCHAR(10), COUNT(*)) + '' times without CHECKSUMS in the past 30 days. CHECKSUMS can help alert you to corruption errors.'' AS [Warning]
978+
''The database '' + QUOTENAME(b.database_name) + '' has been backed up '' + CONVERT(VARCHAR(10), COUNT(*)) + '' times without CHECKSUMS. CHECKSUMS can help alert you to corruption errors.'' AS [Warning]
979979
FROM ' + QUOTENAME(@MSDBName) + N'.dbo.backupset AS b
980980
WHERE b.has_backup_checksums = 0
981-
AND b.backup_finish_date >= DATEADD(DAY, -30, SYSDATETIME())
981+
AND b.backup_finish_date >= @StartTime
982982
GROUP BY b.database_name;' + @crlf;
983983

984984
IF @Debug = 1
985985
PRINT @StringToExecute;
986986

987987
INSERT #Warnings ( CheckId, Priority, DatabaseName, Finding, Warning )
988-
EXEC sys.sp_executesql @StringToExecute;
989-
988+
EXEC sys.sp_executesql @StringToExecute, N'@StartTime DATETIME2', @StartTime;
989+
990990
/*Damaged is a Black Flag album. You don''t want your backups to be like a Black Flag album. */
991991

992992
SET @StringToExecute = N'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;' + @crlf;
@@ -1089,17 +1089,17 @@ IF @ProductVersionMajor >= 12
10891089
100 AS [Priority],
10901090
b.database_name AS [Database Name],
10911091
''Uncompressed backups'' AS [Finding],
1092-
''The database '' + QUOTENAME(b.database_name) + '' has had '' + CONVERT(VARCHAR(10), COUNT(*)) + '' uncompressed backups in the last 30 days. This is a free way to save time and space. And SPACETIME. If your version of SQL supports it.'' AS [Warning]
1092+
''The database '' + QUOTENAME(b.database_name) + '' has had '' + CONVERT(VARCHAR(10), COUNT(*)) + '' uncompressed backups. This is a free way to save time and space. And SPACETIME. If your version of SQL supports it.'' AS [Warning]
10931093
FROM ' + QUOTENAME(@MSDBName) + '.dbo.backupset AS b
10941094
WHERE backup_size = compressed_backup_size AND type = ''D''
1095-
AND b.backup_finish_date >= DATEADD(DAY, -30, SYSDATETIME())
1095+
AND b.backup_finish_date >= @StartTime
10961096
GROUP BY b.database_name;' + @crlf;
10971097

10981098
IF @Debug = 1
10991099
PRINT @StringToExecute;
11001100

11011101
INSERT #Warnings ( CheckId, Priority, DatabaseName, Finding, Warning )
1102-
EXEC sys.sp_executesql @StringToExecute;
1102+
EXEC sys.sp_executesql @StringToExecute, N'@StartTime DATETIME2', @StartTime;
11031103

11041104
/*Looking for backups directed at the NUL device.*/
11051105
SET @StringToExecute =N'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;' + @crlf;

0 commit comments

Comments
 (0)