|
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 | | - |
5 | 1 | IF OBJECT_ID('dbo.sp_Blitz') IS NULL |
6 | 2 | EXEC ('CREATE PROCEDURE dbo.sp_Blitz AS RETURN 0;') |
7 | 3 | GO |
@@ -33,11 +29,11 @@ ALTER PROCEDURE [dbo].[sp_Blitz] |
33 | 29 | AS |
34 | 30 | SET NOCOUNT ON; |
35 | 31 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; |
36 | | - SELECT @Version = 51, @VersionDate = '20160518' |
| 32 | + SELECT @Version = 52, @VersionDate = '20160602' |
37 | 33 |
|
38 | 34 | IF @Help = 1 PRINT ' |
39 | 35 | /* |
40 | | - sp_Blitz (TM) v51 - 2016/05/18 |
| 36 | + sp_Blitz (TM) v52 - 2016/06/02 |
41 | 37 |
|
42 | 38 | (C) 2016, Brent Ozar Unlimited. |
43 | 39 | See http://BrentOzar.com/go/eula for the End User Licensing Agreement. |
|
50 | 46 | To contribute code: http://www.brentozar.com/contributing-code/ |
51 | 47 |
|
52 | 48 | 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. |
54 | 50 | - If a database name has a question mark in it, some tests will fail. Gotta |
55 | 51 | love that unsupported sp_MSforeachdb. |
56 | 52 | - If you have offline databases, sp_Blitz fails the first time you run it, |
|
59 | 55 | Unknown limitations of this version: |
60 | 56 | - None. (If we knew them, they would be known. Duh.) |
61 | 57 |
|
| 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 | +
|
62 | 67 | Changes in v51 - 2016/05/18 |
63 | 68 | - Thomas Rushton added a check for dangerous third-party modules. (179) |
64 | 69 | More info: https://support.microsoft.com/en-us/kb/2033238 |
|
80 | 85 | RDS does not allow you to query MSDB, configure TempDB, make |
81 | 86 | server-level sp_configure settings, etc. |
82 | 87 |
|
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 | | -
|
114 | 88 | For prior changes, see: http://www.BrentOzar.com/blitz/changelog/ |
115 | 89 |
|
116 | 90 |
|
|
236 | 210 | set @base_tracefilename = left( @curr_tracefilename,len(@curr_tracefilename) - @indx) + '\log.trc' ; |
237 | 211 | END |
238 | 212 |
|
| 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 |
239 | 222 |
|
240 | 223 |
|
241 | 224 | /* If the server is Amazon RDS, skip checks that it doesn't allow */ |
|
769 | 752 | WHERE l.sysadmin = 1 |
770 | 753 | AND l.name <> SUSER_SNAME(0x01) |
771 | 754 | 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 */ |
773 | 757 | END |
774 | 758 |
|
775 | 759 | IF NOT EXISTS ( SELECT 1 |
@@ -3047,10 +3031,12 @@ AS |
3047 | 3031 | SELECT 'is_parameterization_forced', 0, 138, 210, 'Forced Parameterization Enabled', 'http://BrentOzar.com/go/dbdefaults', NULL |
3048 | 3032 | FROM sys.all_columns |
3049 | 3033 | 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: |
3050 | 3035 | INSERT INTO #DatabaseDefaults |
3051 | 3036 | SELECT 'is_query_store_on', 0, 139, 210, 'Query Store Enabled', 'http://BrentOzar.com/go/dbdefaults', NULL |
3052 | 3037 | FROM sys.all_columns |
3053 | 3038 | WHERE name = 'is_query_store_on' AND object_id = OBJECT_ID('sys.databases'); |
| 3039 | + */ |
3054 | 3040 | INSERT INTO #DatabaseDefaults |
3055 | 3041 | SELECT 'is_cdc_enabled', 0, 140, 210, 'Change Data Capture Enabled', 'http://BrentOzar.com/go/dbdefaults', NULL |
3056 | 3042 | FROM sys.all_columns |
@@ -3081,10 +3067,17 @@ AS |
3081 | 3067 | WHILE @@FETCH_STATUS = 0 |
3082 | 3068 | BEGIN |
3083 | 3069 |
|
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);'; |
3088 | 3081 | EXEC (@StringToExecute); |
3089 | 3082 |
|
3090 | 3083 | FETCH NEXT FROM DatabaseDefaultsLoop into @CurrentName, @CurrentDefaultValue, @CurrentCheckID, @CurrentPriority, @CurrentFinding, @CurrentURL, @CurrentDetails |
@@ -3513,7 +3506,7 @@ IF @ProductVersionMajor >= 10 AND @ProductVersionMinor >= 50 |
3513 | 3506 | ''Query Store Disabled'', |
3514 | 3507 | ''http://BrentOzar.com/go/querystore'', |
3515 | 3508 | (''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'')'; |
3517 | 3510 | END |
3518 | 3511 |
|
3519 | 3512 |
|
@@ -3754,7 +3747,7 @@ IF @ProductVersionMajor >= 10 AND @ProductVersionMinor >= 50 |
3754 | 3747 | INNER JOIN sys.databases sd ON sd.name = ''?'' |
3755 | 3748 | 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 |
3756 | 3749 | 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'''; |
3758 | 3751 | END |
3759 | 3752 |
|
3760 | 3753 | IF NOT EXISTS ( SELECT 1 |
@@ -3806,7 +3799,7 @@ IF @ProductVersionMajor >= 10 AND @ProductVersionMinor >= 50 |
3806 | 3799 | INNER JOIN sys.databases sd ON sd.name = ''?'' |
3807 | 3800 | 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 |
3808 | 3801 | 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'''; |
3810 | 3803 | END |
3811 | 3804 |
|
3812 | 3805 | IF NOT EXISTS ( SELECT 1 |
@@ -4223,7 +4216,7 @@ IF @ProductVersionMajor >= 10 AND @ProductVersionMinor >= 50 |
4223 | 4216 | FROM #SkipChecks |
4224 | 4217 | WHERE DatabaseName IS NULL AND CheckID = 80 ) |
4225 | 4218 | 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'' '; |
4227 | 4220 | END |
4228 | 4221 |
|
4229 | 4222 | END /* IF @CheckUserDatabaseObjects = 1 */ |
@@ -5341,7 +5334,8 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1 |
5341 | 5334 | 'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP', |
5342 | 5335 | 'REDO_THREAD_PENDING_WORK', |
5343 | 5336 | 'UCS_SESSION_REGISTRATION', |
5344 | | - 'BROKER_TRANSMITTER')) |
| 5337 | + 'BROKER_TRANSMITTER', |
| 5338 | + 'QDS_ASYNC_QUEUE')) |
5345 | 5339 | BEGIN |
5346 | 5340 | /* Check for waits that have had more than 10% of the server's wait time */ |
5347 | 5341 | WITH os(wait_type, waiting_tasks_count, wait_time_ms, max_wait_time_ms, signal_wait_time_ms) |
|
0 commit comments