Skip to content

Commit 75c3596

Browse files
committed
Merge pull request #272 from BrentOzarULTD/feature-271-sql2016-compat
Feature 271 sql2016 compat
2 parents 6348b34 + 7e5e55e commit 75c3596

File tree

1 file changed

+42
-48
lines changed

1 file changed

+42
-48
lines changed

sp_Blitz.sql

Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
IF EXISTS(SELECT * FROM sys.databases WHERE compatibility_level < 80)
2-
RAISERROR ('sp_Blitz cannot be installed when databases are in pre-2000 compatibility mode. For information: http://BrentOzar.com/blitz/', 10,1) WITH LOG, NOWAIT;
3-
GO
4-
51
IF OBJECT_ID('dbo.sp_Blitz') IS NULL
62
EXEC ('CREATE PROCEDURE dbo.sp_Blitz AS RETURN 0;')
73
GO
@@ -33,11 +29,11 @@ ALTER PROCEDURE [dbo].[sp_Blitz]
3329
AS
3430
SET NOCOUNT ON;
3531
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
36-
SELECT @Version = 51, @VersionDate = '20160518'
32+
SELECT @Version = 52, @VersionDate = '20160602'
3733

3834
IF @Help = 1 PRINT '
3935
/*
40-
sp_Blitz (TM) v51 - 2016/05/18
36+
sp_Blitz (TM) v52 - 2016/06/02
4137
4238
(C) 2016, Brent Ozar Unlimited.
4339
See http://BrentOzar.com/go/eula for the End User Licensing Agreement.
@@ -50,7 +46,7 @@ AS
5046
To contribute code: http://www.brentozar.com/contributing-code/
5147
5248
Known limitations of this version:
53-
- No support for SQL Server 2000 or compatibility mode 80.
49+
- Only Microsoft-supported versions of SQL Server. Sorry, 2005 and 2000.
5450
- If a database name has a question mark in it, some tests will fail. Gotta
5551
love that unsupported sp_MSforeachdb.
5652
- If you have offline databases, sp_Blitz fails the first time you run it,
@@ -59,6 +55,15 @@ AS
5955
Unknown limitations of this version:
6056
- None. (If we knew them, they would be known. Duh.)
6157
58+
Changes in v52 - 2016/06/02
59+
- SQL Server 2016 compatibility. 2016 RTM ships with some questionable
60+
database-level options like heaps in DWDiagnostics, target recovery
61+
time changed in the DW* databases, and l_certSignSmDetach as a new
62+
default sysadmin login, so ignoring those.
63+
- If databases have an old compatibility level that does not support CTEs
64+
then @CheckUserDatabaseObjects is set to 0 to avoid problems with
65+
current checks. Get on the current compat level, Grandpa.
66+
6267
Changes in v51 - 2016/05/18
6368
- Thomas Rushton added a check for dangerous third-party modules. (179)
6469
More info: https://support.microsoft.com/en-us/kb/2033238
@@ -80,37 +85,6 @@ AS
8085
RDS does not allow you to query MSDB, configure TempDB, make
8186
server-level sp_configure settings, etc.
8287
83-
Changes in v48 - 2016/03/20
84-
- Julie Citro massively improved the check for stored procedures with a
85-
recompile hint in them. (78)
86-
- These new checks brought to you by Erik Darling:
87-
- Multiple Extended Events sessions running (176)
88-
- Startup parameter -x in use, disabling monitoring (177)
89-
- TempDB has >16 data files (175)
90-
- Along with some changes:
91-
- Improved full text repopulation check to ignore change_tracking_state_desc AUTO (113)
92-
- DBCC CHECKDB checks now ignore TempDB (68)
93-
- Poison wait times are now reported in Days:Hours:Minutes, and are only
94-
reported if they exceed 60 seconds (instead of 5)
95-
- The missing log backups alert now includes the log file size.
96-
- Trace flag alerts now include more details about dangerous trace flags.
97-
- Some per-database checks were running even when @CheckUserDatabaseObjects
98-
was set to 0. (Performance tuning sp_Blitz for thousands of databases.)
99-
- The high number of cached plans warning (161) reported the wrong limit for cached
100-
plans in the detail message.
101-
102-
Changes in v47 - 2016/03/12
103-
- These new changes brought to you by Erik Darling:
104-
- Locked pages in memory (check 166)
105-
- Agent currently offline (167)
106-
- Full text daemon offline (168)
107-
- SQL Server running as NT Service rather than an AD account (169)
108-
- Agent running as NT Service rather than an AD account (170)
109-
- Memory dumps in the last year (171)
110-
- Windows version (172)
111-
- Dev or Evaluation Edition in use (173)
112-
- Buffer Pool Extension enabled (174)
113-
11488
For prior changes, see: http://www.BrentOzar.com/blitz/changelog/
11589
11690
@@ -236,6 +210,15 @@ AS
236210
set @base_tracefilename = left( @curr_tracefilename,len(@curr_tracefilename) - @indx) + '\log.trc' ;
237211
END
238212

213+
/* If the server has any databases on Antiques Roadshow, skip the checks that would break due to CTEs. */
214+
IF @CheckUserDatabaseObjects = 1 AND EXISTS(SELECT * FROM sys.databases WHERE compatibility_level < 90)
215+
BEGIN
216+
SET @CheckUserDatabaseObjects = 0;
217+
PRINT 'Databases with compatibility level < 90 found, so setting @CheckUserDatabaseObjects = 0.';
218+
PRINT 'The database-level checks rely on CTEs, which are not supported in SQL 2000 compat level databases.';
219+
PRINT 'Get with the cool kids and switch to a current compatibility level, Grandpa. To find the problems, run:';
220+
PRINT 'SELECT * FROM sys.databases WHERE compatibility_level < 90;';
221+
END
239222

240223

241224
/* If the server is Amazon RDS, skip checks that it doesn't allow */
@@ -769,7 +752,8 @@ AS
769752
WHERE l.sysadmin = 1
770753
AND l.name <> SUSER_SNAME(0x01)
771754
AND l.denylogin = 0
772-
AND l.name NOT LIKE 'NT SERVICE\%';
755+
AND l.name NOT LIKE 'NT SERVICE\%'
756+
AND l.name <> 'l_certSignSmDetach'; /* Added in SQL 2016 */
773757
END
774758

775759
IF NOT EXISTS ( SELECT 1
@@ -3047,10 +3031,12 @@ AS
30473031
SELECT 'is_parameterization_forced', 0, 138, 210, 'Forced Parameterization Enabled', 'http://BrentOzar.com/go/dbdefaults', NULL
30483032
FROM sys.all_columns
30493033
WHERE name = 'is_parameterization_forced' AND object_id = OBJECT_ID('sys.databases');
3034+
/* Not alerting for this since we actually want it and we have a separate check for it:
30503035
INSERT INTO #DatabaseDefaults
30513036
SELECT 'is_query_store_on', 0, 139, 210, 'Query Store Enabled', 'http://BrentOzar.com/go/dbdefaults', NULL
30523037
FROM sys.all_columns
30533038
WHERE name = 'is_query_store_on' AND object_id = OBJECT_ID('sys.databases');
3039+
*/
30543040
INSERT INTO #DatabaseDefaults
30553041
SELECT 'is_cdc_enabled', 0, 140, 210, 'Change Data Capture Enabled', 'http://BrentOzar.com/go/dbdefaults', NULL
30563042
FROM sys.all_columns
@@ -3081,10 +3067,17 @@ AS
30813067
WHILE @@FETCH_STATUS = 0
30823068
BEGIN
30833069

3084-
SET @StringToExecute = 'INSERT INTO #BlitzResults (CheckID, DatabaseName, Priority, FindingsGroup, Finding, URL, Details)
3085-
SELECT ' + CAST(@CurrentCheckID AS NVARCHAR(200)) + ', d.[name], ' + CAST(@CurrentPriority AS NVARCHAR(200)) + ', ''Non-Default Database Config'', ''' + @CurrentFinding + ''',''' + @CurrentURL + ''',''' + COALESCE(@CurrentDetails, 'This database setting is not the default.') + '''
3086-
FROM sys.databases d
3087-
WHERE d.database_id > 4 AND (d.[' + @CurrentName + '] <> ' + @CurrentDefaultValue + ' OR d.[' + @CurrentName + '] IS NULL);';
3070+
/* DW* databases ship with Target Recovery Time (142) set to a non-default number */
3071+
IF @CurrentCheckID = 142
3072+
SET @StringToExecute = 'INSERT INTO #BlitzResults (CheckID, DatabaseName, Priority, FindingsGroup, Finding, URL, Details)
3073+
SELECT ' + CAST(@CurrentCheckID AS NVARCHAR(200)) + ', d.[name], ' + CAST(@CurrentPriority AS NVARCHAR(200)) + ', ''Non-Default Database Config'', ''' + @CurrentFinding + ''',''' + @CurrentURL + ''',''' + COALESCE(@CurrentDetails, 'This database setting is not the default.') + '''
3074+
FROM sys.databases d
3075+
WHERE d.database_id > 4 AND d.[name] NOT IN (''DWConfiguration'', ''DWDiagnostics'', ''DWQueue'') AND (d.[' + @CurrentName + '] <> ' + @CurrentDefaultValue + ' OR d.[' + @CurrentName + '] IS NULL);';
3076+
ELSE
3077+
SET @StringToExecute = 'INSERT INTO #BlitzResults (CheckID, DatabaseName, Priority, FindingsGroup, Finding, URL, Details)
3078+
SELECT ' + CAST(@CurrentCheckID AS NVARCHAR(200)) + ', d.[name], ' + CAST(@CurrentPriority AS NVARCHAR(200)) + ', ''Non-Default Database Config'', ''' + @CurrentFinding + ''',''' + @CurrentURL + ''',''' + COALESCE(@CurrentDetails, 'This database setting is not the default.') + '''
3079+
FROM sys.databases d
3080+
WHERE d.database_id > 4 AND (d.[' + @CurrentName + '] <> ' + @CurrentDefaultValue + ' OR d.[' + @CurrentName + '] IS NULL);';
30883081
EXEC (@StringToExecute);
30893082

30903083
FETCH NEXT FROM DatabaseDefaultsLoop into @CurrentName, @CurrentDefaultValue, @CurrentCheckID, @CurrentPriority, @CurrentFinding, @CurrentURL, @CurrentDetails
@@ -3513,7 +3506,7 @@ IF @ProductVersionMajor >= 10 AND @ProductVersionMinor >= 50
35133506
''Query Store Disabled'',
35143507
''http://BrentOzar.com/go/querystore'',
35153508
(''The new SQL Server 2016 Query Store feature has not been enabled on this database.'')
3516-
FROM [?].sys.database_query_store_options WHERE desired_state = 0 AND ''?'' NOT IN (''master'', ''model'', ''msdb'', ''tempdb'', ''ReportServer'', ''ReportServerTempDB'')';
3509+
FROM [?].sys.database_query_store_options WHERE desired_state = 0 AND ''?'' NOT IN (''master'', ''model'', ''msdb'', ''tempdb'', ''DWConfiguration'', ''DWDiagnostics'', ''DWQueue'', ''ReportServer'', ''ReportServerTempDB'')';
35173510
END
35183511

35193512

@@ -3754,7 +3747,7 @@ IF @ProductVersionMajor >= 10 AND @ProductVersionMinor >= 50
37543747
INNER JOIN sys.databases sd ON sd.name = ''?''
37553748
LEFT OUTER JOIN [?].sys.dm_db_index_usage_stats ius ON i.object_id = ius.object_id AND i.index_id = ius.index_id AND ius.database_id = sd.database_id
37563749
WHERE i.type_desc = ''HEAP'' AND COALESCE(ius.user_seeks, ius.user_scans, ius.user_lookups, ius.user_updates) IS NOT NULL
3757-
AND sd.name <> ''tempdb'' AND o.is_ms_shipped = 0 AND o.type <> ''S''';
3750+
AND sd.name <> ''tempdb'' AND sd.name <> ''DWDiagnostics'' AND o.is_ms_shipped = 0 AND o.type <> ''S''';
37583751
END
37593752

37603753
IF NOT EXISTS ( SELECT 1
@@ -3806,7 +3799,7 @@ IF @ProductVersionMajor >= 10 AND @ProductVersionMinor >= 50
38063799
INNER JOIN sys.databases sd ON sd.name = ''?''
38073800
LEFT OUTER JOIN [?].sys.dm_db_index_usage_stats ius ON i.object_id = ius.object_id AND i.index_id = ius.index_id AND ius.database_id = sd.database_id
38083801
WHERE i.type_desc = ''HEAP'' AND COALESCE(ius.user_seeks, ius.user_scans, ius.user_lookups, ius.user_updates) IS NULL
3809-
AND sd.name <> ''tempdb'' AND o.is_ms_shipped = 0 AND o.type <> ''S''';
3802+
AND sd.name <> ''tempdb'' AND sd.name <> ''DWDiagnostics'' AND o.is_ms_shipped = 0 AND o.type <> ''S''';
38103803
END
38113804

38123805
IF NOT EXISTS ( SELECT 1
@@ -4223,7 +4216,7 @@ IF @ProductVersionMajor >= 10 AND @ProductVersionMinor >= 50
42234216
FROM #SkipChecks
42244217
WHERE DatabaseName IS NULL AND CheckID = 80 )
42254218
BEGIN
4226-
EXEC dbo.sp_MSforeachdb 'USE [?]; INSERT INTO #BlitzResults (CheckID, DatabaseName, Priority, FindingsGroup, Finding, URL, Details) SELECT DISTINCT 80, DB_NAME(), 170, ''Reliability'', ''Max File Size Set'', ''http://BrentOzar.com/go/maxsize'', (''The ['' + DB_NAME() + ''] database file '' + name + '' has a max file size set to '' + CAST(CAST(max_size AS BIGINT) * 8 / 1024 AS VARCHAR(100)) + ''MB. If it runs out of space, the database will stop working even though there may be drive space available.'') FROM sys.database_files WHERE max_size <> 268435456 AND max_size <> -1 AND type <> 2';
4219+
EXEC dbo.sp_MSforeachdb 'USE [?]; INSERT INTO #BlitzResults (CheckID, DatabaseName, Priority, FindingsGroup, Finding, URL, Details) SELECT DISTINCT 80, DB_NAME(), 170, ''Reliability'', ''Max File Size Set'', ''http://BrentOzar.com/go/maxsize'', (''The ['' + DB_NAME() + ''] database file '' + name + '' has a max file size set to '' + CAST(CAST(max_size AS BIGINT) * 8 / 1024 AS VARCHAR(100)) + ''MB. If it runs out of space, the database will stop working even though there may be drive space available.'') FROM sys.database_files WHERE max_size <> 268435456 AND max_size <> -1 AND type <> 2 AND name <> ''DWDiagnostics'' ';
42274220
END
42284221

42294222
END /* IF @CheckUserDatabaseObjects = 1 */
@@ -5341,7 +5334,8 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
53415334
'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP',
53425335
'REDO_THREAD_PENDING_WORK',
53435336
'UCS_SESSION_REGISTRATION',
5344-
'BROKER_TRANSMITTER'))
5337+
'BROKER_TRANSMITTER',
5338+
'QDS_ASYNC_QUEUE'))
53455339
BEGIN
53465340
/* Check for waits that have had more than 10% of the server's wait time */
53475341
WITH os(wait_type, waiting_tasks_count, wait_time_ms, max_wait_time_ms, signal_wait_time_ms)

0 commit comments

Comments
 (0)