Skip to content

Commit c344281

Browse files
committed
Fix stuff
Notes in PR
1 parent addfb45 commit c344281

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

sp_Blitz.sql

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,8 @@ AS
859859
BEGIN
860860
IF DATEADD(dd, -60, GETDATE()) > (SELECT TOP 1 backup_start_date FROM msdb.dbo.backupset ORDER BY 1)
861861

862+
BEGIN
863+
862864
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 3) WITH NOWAIT;
863865

864866
INSERT INTO #BlitzResults
@@ -881,13 +883,16 @@ AS
881883
+ CAST(bs.backup_start_date AS VARCHAR(20)) ) AS Details
882884
FROM msdb.dbo.backupset bs
883885
ORDER BY backup_set_id ASC;
886+
END;
884887
END;
885888

886889
IF NOT EXISTS ( SELECT 1
887890
FROM #SkipChecks
888891
WHERE DatabaseName IS NULL AND CheckID = 186 )
889892
BEGIN
890893
IF DATEADD(dd, -2, GETDATE()) < (SELECT TOP 1 backup_start_date FROM msdb.dbo.backupset ORDER BY 1)
894+
895+
BEGIN
891896

892897
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 186) WITH NOWAIT;
893898

@@ -911,6 +916,7 @@ AS
911916
+ CAST(bs.backup_start_date AS VARCHAR(20)) ) AS Details
912917
FROM msdb.dbo.backupset bs
913918
ORDER BY backup_set_id ASC;
919+
END;
914920
END;
915921

916922
IF NOT EXISTS ( SELECT 1
@@ -1960,6 +1966,8 @@ AS
19601966
WHERE severity BETWEEN 19 AND 25
19611967
) < 7
19621968

1969+
BEGIN
1970+
19631971
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 30) WITH NOWAIT;
19641972

19651973
INSERT INTO #BlitzResults
@@ -1976,6 +1984,7 @@ AS
19761984
'Not All Alerts Configured' AS Finding ,
19771985
'https://BrentOzar.com/go/alert' AS URL ,
19781986
( 'Not all SQL Server Agent alerts have been configured. This is a free, easy way to get notified of corruption, job failures, or major outages even before monitoring systems pick it up.' ) AS Details;
1987+
END;
19791988
END;
19801989

19811990

@@ -1990,6 +1999,8 @@ AS
19901999
AND COALESCE(has_notification, 0) = 0
19912000
AND (job_id IS NULL OR job_id = 0x))
19922001

2002+
BEGIN
2003+
19932004
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 59) WITH NOWAIT;
19942005

19952006
INSERT INTO #BlitzResults
@@ -2006,6 +2017,8 @@ AS
20062017
'Alerts Configured without Follow Up' AS Finding ,
20072018
'https://BrentOzar.com/go/alert' AS URL ,
20082019
( 'SQL Server Agent alerts have been configured but they either do not notify anyone or else they do not take any action. This is a free, easy way to get notified of corruption, job failures, or major outages even before monitoring systems pick it up.' ) AS Details;
2020+
2021+
END;
20092022
END;
20102023

20112024
IF NOT EXISTS ( SELECT 1
@@ -2016,6 +2029,8 @@ AS
20162029
FROM msdb.dbo.sysalerts
20172030
WHERE message_id IN ( 823, 824, 825 ) )
20182031

2032+
BEGIN;
2033+
20192034
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 96) WITH NOWAIT;
20202035

20212036
INSERT INTO #BlitzResults
@@ -2032,6 +2047,8 @@ AS
20322047
'No Alerts for Corruption' AS Finding ,
20332048
'https://BrentOzar.com/go/alert' AS URL ,
20342049
( 'SQL Server Agent alerts do not exist for errors 823, 824, and 825. These three errors can give you notification about early hardware failure. Enabling them can prevent you a lot of heartbreak.' ) AS Details;
2050+
2051+
END;
20352052
END;
20362053

20372054

@@ -2043,6 +2060,8 @@ AS
20432060
FROM msdb.dbo.sysalerts
20442061
WHERE severity BETWEEN 19 AND 25 )
20452062

2063+
BEGIN
2064+
20462065
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 61) WITH NOWAIT;
20472066

20482067
INSERT INTO #BlitzResults
@@ -2059,6 +2078,9 @@ AS
20592078
'No Alerts for Sev 19-25' AS Finding ,
20602079
'https://BrentOzar.com/go/alert' AS URL ,
20612080
( 'SQL Server Agent alerts do not exist for severity levels 19 through 25. These are some very severe SQL Server errors. Knowing that these are happening may let you recover from errors faster.' ) AS Details;
2081+
2082+
END;
2083+
20622084
END;
20632085

20642086
--check for disabled alerts
@@ -2070,6 +2092,8 @@ AS
20702092
FROM msdb.dbo.sysalerts
20712093
WHERE enabled = 0 )
20722094

2095+
BEGIN
2096+
20732097
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 98) WITH NOWAIT;
20742098

20752099
INSERT INTO #BlitzResults
@@ -2089,6 +2113,9 @@ AS
20892113
+ name ) AS Details
20902114
FROM msdb.dbo.sysalerts
20912115
WHERE enabled = 0;
2116+
2117+
END;
2118+
20922119
END;
20932120

20942121

@@ -2100,6 +2127,8 @@ AS
21002127
FROM msdb.dbo.sysoperators
21012128
WHERE enabled = 1 )
21022129

2130+
BEGIN
2131+
21032132
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 31) WITH NOWAIT;
21042133

21052134
INSERT INTO #BlitzResults
@@ -2116,6 +2145,8 @@ AS
21162145
'No Operators Configured/Enabled' AS Finding ,
21172146
'https://BrentOzar.com/go/op' AS URL ,
21182147
( 'No SQL Server Agent operators (emails) have been configured. This is a free, easy way to get notified of corruption, job failures, or major outages even before monitoring systems pick it up.' ) AS Details;
2148+
2149+
END;
21192150
END;
21202151

21212152

@@ -2337,6 +2368,13 @@ AS
23372368
END;
23382369
END;
23392370

2371+
2372+
IF NOT EXISTS ( SELECT 1
2373+
FROM #SkipChecks
2374+
WHERE DatabaseName IS NULL AND CheckID = 183 )
2375+
2376+
BEGIN
2377+
23402378
IF ( SELECT COUNT (distinct [size])
23412379
FROM tempdb.sys.database_files
23422380
WHERE type_desc = 'ROWS'
@@ -2364,6 +2402,7 @@ AS
23642402
'TempDB data files are not configured with the same size. Unevenly sized tempdb data files will result in unevenly sized workloads.'
23652403
);
23662404
END;
2405+
END;
23672406

23682407
IF NOT EXISTS ( SELECT 1
23692408
FROM #SkipChecks
@@ -3148,6 +3187,9 @@ AS
31483187

31493188

31503189
IF DATEADD(mi, -15, GETDATE()) < (SELECT TOP 1 creation_time FROM sys.dm_exec_query_stats ORDER BY creation_time)
3190+
AND NOT EXISTS ( SELECT 1
3191+
FROM #SkipChecks
3192+
WHERE DatabaseName IS NULL AND CheckID = 125 )
31513193
BEGIN
31523194

31533195
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 125) WITH NOWAIT;
@@ -3166,6 +3208,9 @@ AS
31663208
END;
31673209

31683210
IF EXISTS (SELECT * FROM sys.configurations WHERE name = 'priority boost' AND (value = 1 OR value_in_use = 1))
3211+
AND NOT EXISTS ( SELECT 1
3212+
FROM #SkipChecks
3213+
WHERE DatabaseName IS NULL AND CheckID = 126 )
31693214
BEGIN
31703215

31713216
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 126) WITH NOWAIT;
@@ -3487,6 +3532,10 @@ AS
34873532

34883533
IF @TraceFileIssue = 1
34893534
BEGIN
3535+
IF NOT EXISTS ( SELECT 1
3536+
FROM #SkipChecks
3537+
WHERE DatabaseName IS NULL AND CheckID = 199 )
3538+
34903539
INSERT INTO #BlitzResults
34913540
( CheckID ,
34923541
DatabaseName ,
@@ -4089,10 +4138,12 @@ IF @ProductVersionMajor >= 10
40894138
IF NOT EXISTS ( SELECT 1
40904139
FROM #SkipChecks
40914140
WHERE DatabaseName IS NULL AND CheckID = 176 )
4141+
BEGIN
4142+
40924143
IF EXISTS ( SELECT 1
40934144
FROM sys.all_objects
40944145
WHERE name = 'dm_xe_sessions' )
4095-
BEGIN
4146+
40964147
BEGIN
40974148

40984149
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 176) WITH NOWAIT;
@@ -4127,6 +4178,7 @@ IF @ProductVersionMajor >= 10
41274178
FROM #SkipChecks
41284179
WHERE DatabaseName IS NULL AND CheckID = 177 )
41294180
BEGIN
4181+
41304182
IF EXISTS ( SELECT 1
41314183
FROM sys.all_objects
41324184
WHERE name = 'dm_server_registry' )
@@ -4483,6 +4535,8 @@ IF @ProductVersionMajor >= 10
44834535
AND d.application_name NOT LIKE '%Red Gate Software Ltd SQL Prompt%'
44844536
AND d.application_name NOT LIKE '%Spotlight Diagnostic Server%'
44854537
AND d.application_name NOT LIKE '%SQL Diagnostic Manager%'
4538+
AND d.application_name NOT LIKE '%Sentry%'
4539+
44864540

44874541
HAVING COUNT(*) > 0;
44884542

@@ -5614,6 +5668,9 @@ IF @ProductVersionMajor >= 10
56145668
END; /* IF @CheckUserDatabaseObjects = 1 */
56155669

56165670
IF @CheckProcedureCache = 1
5671+
5672+
IF @Debug IN (1, 2) RAISERROR('Begin checking procedure cache', 0, 1) WITH NOWAIT;
5673+
56175674
BEGIN
56185675

56195676
IF NOT EXISTS ( SELECT 1

0 commit comments

Comments
 (0)