Skip to content

Commit 92c2dac

Browse files
authored
Merge pull request BrentOzarULTD#641 from BrentOzarULTD/issue_598/brent
BrentOzarULTD#598 sp_Blitz add checks for database_scoped_configurations
2 parents 1827ac5 + 4cdb470 commit 92c2dac

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

Documentation/sp_Blitz Checks by Priority.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ If you want to change anything about a check - the priority, finding, URL, or ID
3939
| 20 | Reliability | Query Store Cleanup Disabled | http://BrentOzar.com/go/cleanup | 182 |
4040
| 20 | Reliability | Unsupported Build of SQL Server | http://BrentOzar.com/go/unsupported | 128 |
4141
| 20 | Reliability | User Databases on C Drive | http://BrentOzar.com/go/cdrive | 26 |
42+
| 20 | Reliability | TempDB on C Drive | http://BrentOzar.com/go/cdrive | 25 |
4243
| 50 | Performance | Instant File Initialization Not Enabled | http://BrentOzar.com/go/instant | 192 |
4344
| 50 | Performance | Log File Growths Slow | http://BrentOzar.com/go/filegrowth | 151 |
4445
| 50 | Performance | Poison Wait Detected: CMEMTHREAD & NUMA | http://BrentOzar.com/go/poison | 162 |
@@ -103,7 +104,6 @@ If you want to change anything about a check - the priority, finding, URL, or ID
103104
| 170 | File Configuration | Multiple Log Files on One Drive | http://BrentOzar.com/go/manylogs | 41 |
104105
| 170 | File Configuration | System Database on C Drive | http://BrentOzar.com/go/drivec | 24 |
105106
| 170 | File Configuration | TempDB Has >16 Data Files | http://BrentOzar.com/go/tempdb | 175 |
106-
| 170 | File Configuration | TempDB on C Drive | http://BrentOzar.com/go/drivec | 25 |
107107
| 170 | File Configuration | TempDB Only Has 1 Data File | http://BrentOzar.com/go/tempdb | 40 |
108108
| 170 | File Configuration | TempDB Unevenly Sized Data Files | http://BrentOzar.com/go/tempdb | 183 |
109109
| 170 | File Configuration | Uneven File Growth Settings in One Filegroup | http://BrentOzar.com/go/grow | 42 |
@@ -236,6 +236,10 @@ If you want to change anything about a check - the priority, finding, URL, or ID
236236
| 210 | Non-Default Database Config | Supplemental Logging Enabled | http://BrentOzar.com/go/dbdefaults | 131 |
237237
| 210 | Non-Default Database Config | Target Recovery Time Changed | http://BrentOzar.com/go/dbdefaults | 142 |
238238
| 210 | Non-Default Database Config | Trustworthy Enabled | http://BrentOzar.com/go/dbdefaults | 137 |
239+
| 210 | Non-Default Database Scoped Config | MAXDOP | http://BrentOzar.com/go/dbscope | 194 |
240+
| 210 | Non-Default Database Scoped Config | Legacy CE | http://BrentOzar.com/go/dbscope | 195 |
241+
| 210 | Non-Default Database Scoped Config | Parameter Sniffing | http://BrentOzar.com/go/dbscope | 196 |
242+
| 210 | Non-Default Database Scoped Config | Query Optimizer Hotfixes | http://BrentOzar.com/go/dbscope | 197 |
239243
| 230 | Security | Control Server Permissions | http://BrentOzar.com/go/sa | 104 |
240244
| 230 | Security | Database Owner <> SA | http://BrentOzar.com/go/owndb | 55 |
241245
| 230 | Security | Elevated Permissions on a Database | http://BrentOzar.com/go/elevated | 86 |

sp_Blitz.sql

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ AS
297297
Details NVARCHAR(4000)
298298
);
299299

300+
IF OBJECT_ID('tempdb..#DatabaseScopedConfigurationDefaults') IS NOT NULL
301+
DROP TABLE #DatabaseScopedConfigurationDefaults;
302+
CREATE TABLE #DatabaseScopedConfigurationDefaults
303+
(ID INT IDENTITY(1,1), configuration_id INT, [name] NVARCHAR(60), default_value sql_variant, default_value_for_secondary sql_variant, CheckID INT, );
304+
300305

301306

302307
IF OBJECT_ID('tempdb..#DBCCs') IS NOT NULL
@@ -1619,7 +1624,7 @@ AS
16191624
SELECT TOP 1
16201625
25 AS CheckID ,
16211626
'tempdb' ,
1622-
170 AS Priority ,
1627+
20 AS Priority ,
16231628
'File Configuration' AS FindingsGroup ,
16241629
'TempDB on C Drive' AS Finding ,
16251630
'http://BrentOzar.com/go/cdrive' AS URL ,
@@ -4607,10 +4612,28 @@ IF @ProductVersionMajor >= 10 AND @ProductVersionMinor >= 50
46074612
IF EXISTS (SELECT * FROM #TemporaryDatabaseResults) SET @ColumnStoreIndexesInUse = 1;
46084613
END
46094614

4610-
IF EXISTS (SELECT * FROM sys.indexes WHERE type IN (5,6))
4611-
BEGIN
4612-
SET @ColumnStoreIndexesInUse = 1
4613-
END
4615+
4616+
/* Non-Default Database Scoped Config - Github issue #598 */
4617+
IF EXISTS ( SELECT * FROM sys.all_objects WHERE [name] = 'database_scoped_configurations' )
4618+
BEGIN
4619+
INSERT INTO #DatabaseScopedConfigurationDefaults (configuration_id, [name], default_value, default_value_for_secondary, CheckID)
4620+
SELECT 1, 'MAXDOP', 0, NULL, 194
4621+
UNION ALL
4622+
SELECT 2, 'LEGACY_CARDINALITY_ESTIMATION', 0, NULL, 195
4623+
UNION ALL
4624+
SELECT 3, 'PARAMETER_SNIFFING', 1, NULL, 196
4625+
UNION ALL
4626+
SELECT 4, 'QUERY_OPTIMIZER_HOTFIXES', 0, NULL, 197;
4627+
EXEC dbo.sp_MSforeachdb 'USE [?]; INSERT INTO #BlitzResults (CheckID, DatabaseName, Priority, FindingsGroup, Finding, URL, Details)
4628+
SELECT def1.CheckID, DB_NAME(), 210, ''Non-Default Database Scoped Config'', dsc.[name], ''http://BrentOzar.com/go/dbscope'', (''Set value: '' + COALESCE(CAST(dsc.value AS NVARCHAR(100)),''Empty'') + '' Default: '' + COALESCE(CAST(def1.default_value AS NVARCHAR(100)),''Empty'') + '' Set value for secondary: '' + COALESCE(CAST(dsc.value_for_secondary AS NVARCHAR(100)),''Empty'') + '' Default value for secondary: '' + COALESCE(CAST(def1.default_value_for_secondary AS NVARCHAR(100)),''Empty''))
4629+
FROM [?].sys.database_scoped_configurations dsc
4630+
INNER JOIN #DatabaseScopedConfigurationDefaults def1 ON dsc.configuration_id = def1.configuration_id
4631+
LEFT OUTER JOIN #DatabaseScopedConfigurationDefaults def ON dsc.configuration_id = def.configuration_id AND (dsc.value = def.default_value OR dsc.value IS NULL) AND (dsc.value_for_secondary = def.default_value_for_secondary OR dsc.value_for_secondary IS NULL)
4632+
LEFT OUTER JOIN #SkipChecks sk ON def.CheckID = sk.CheckID AND (sk.DatabaseName IS NULL OR sk.DatabaseName = DB_NAME())
4633+
WHERE def.configuration_id IS NULL AND sk.CheckID IS NULL ORDER BY 1';
4634+
END
4635+
4636+
46144637

46154638

46164639
END /* IF @CheckUserDatabaseObjects = 1 */
@@ -6214,6 +6237,7 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
62146237
ORDER BY Priority ,
62156238
FindingsGroup ,
62166239
Finding ,
6240+
DatabaseName ,
62176241
Details;
62186242
END
62196243
ELSE IF @OutputXMLasNVARCHAR = 1 AND @OutputType <> 'NONE'
@@ -6231,6 +6255,7 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
62316255
ORDER BY Priority ,
62326256
FindingsGroup ,
62336257
Finding ,
6258+
DatabaseName ,
62346259
Details;
62356260
END
62366261
ELSE IF @OutputType = 'MARKDOWN'
@@ -6269,6 +6294,7 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
62696294
ORDER BY Priority ,
62706295
FindingsGroup ,
62716296
Finding ,
6297+
DatabaseName ,
62726298
Details;
62736299
END
62746300

0 commit comments

Comments
 (0)