Skip to content

Commit

Permalink
Merge pull request #3323 from BrentOzarULTD/dev
Browse files Browse the repository at this point in the history
2023-08-20 Release
  • Loading branch information
BrentOzar authored Aug 20, 2023
2 parents 4f8b641 + 0f4c26b commit 49d64cb
Show file tree
Hide file tree
Showing 18 changed files with 3,234 additions and 717 deletions.
983 changes: 799 additions & 184 deletions Install-All-Scripts.sql

Large diffs are not rendered by default.

951 changes: 780 additions & 171 deletions Install-Core-Blitz-No-Query-Store.sql

Large diffs are not rendered by default.

953 changes: 781 additions & 172 deletions Install-Core-Blitz-With-Query-Store.sql

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions SqlServerVersions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ DELETE FROM dbo.SqlServerVersions;
INSERT INTO dbo.SqlServerVersions
(MajorVersionNumber, MinorVersionNumber, Branch, [Url], ReleaseDate, MainstreamSupportEndDate, ExtendedSupportEndDate, MajorVersionName, MinorVersionName)
VALUES
(16, 4065, 'CU7', 'https://support.microsoft.com/en-us/help/5028743', '2023-08-10', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 7'),
(16, 4055, 'CU6', 'https://support.microsoft.com/en-us/help/5027505', '2023-07-13', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 6'),
(16, 4045, 'CU5', 'https://support.microsoft.com/en-us/help/5026806', '2023-06-15', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 5'),
(16, 4035, 'CU4', 'https://support.microsoft.com/en-us/help/5026717', '2023-05-11', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 4'),
(16, 4025, 'CU3', 'https://support.microsoft.com/en-us/help/5024396', '2023-04-13', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 3'),
(16, 4015, 'CU2', 'https://support.microsoft.com/en-us/help/5023127', '2023-03-15', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 2'),
(16, 4003, 'CU1', 'https://support.microsoft.com/en-us/help/5022375', '2023-02-16', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 1'),
(16, 1050, 'RTM GDR', 'https://support.microsoft.com/kb/5021522', '2023-02-14', '2028-01-11', '2033-01-11', 'SQL Server 2022 GDR', 'RTM'),
(16, 1000, 'RTM', '', '2022-11-15', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'RTM'),
(15, 4322, 'CU22', 'https://support.microsoft.com/kb/5027702', '2023-08-14', '2025-01-07', '2030-01-08', 'SQL Server 2019', 'Cumulative Update 22'),
(15, 4316, 'CU21', 'https://support.microsoft.com/kb/5025808', '2023-06-15', '2025-01-07', '2030-01-08', 'SQL Server 2019', 'Cumulative Update 21'),
(15, 4312, 'CU20', 'https://support.microsoft.com/kb/5024276', '2023-04-13', '2025-01-07', '2030-01-08', 'SQL Server 2019', 'Cumulative Update 20'),
(15, 4298, 'CU19', 'https://support.microsoft.com/kb/5023049', '2023-02-16', '2025-01-07', '2030-01-08', 'SQL Server 2019', 'Cumulative Update 19'),
(15, 4280, 'CU18 GDR', 'https://support.microsoft.com/kb/5021124', '2023-02-14', '2025-01-07', '2030-01-08', 'SQL Server 2019', 'Cumulative Update 18 GDR'),
Expand Down
2 changes: 1 addition & 1 deletion sp_AllNightLog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SET STATISTICS XML OFF;
BEGIN;


SELECT @Version = '8.15', @VersionDate = '20230613';
SELECT @Version = '8.16', @VersionDate = '20230820';

IF(@VersionCheckMode = 1)
BEGIN
Expand Down
2 changes: 1 addition & 1 deletion sp_AllNightLog_Setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SET STATISTICS XML OFF;

BEGIN;

SELECT @Version = '8.15', @VersionDate = '20230613';
SELECT @Version = '8.16', @VersionDate = '20230820';

IF(@VersionCheckMode = 1)
BEGIN
Expand Down
286 changes: 234 additions & 52 deletions sp_Blitz.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ AS
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;


SELECT @Version = '8.15', @VersionDate = '20230613';
SELECT @Version = '8.16', @VersionDate = '20230820';
SET @OutputType = UPPER(@OutputType);

IF(@VersionCheckMode = 1)
Expand Down Expand Up @@ -186,11 +186,129 @@ AS
,@CurrentComponentVersionCheckModeOK BIT
,@canExitLoop BIT
,@frkIsConsistent BIT
,@NeedToTurnNumericRoundabortBackOn BIT;
,@NeedToTurnNumericRoundabortBackOn BIT
,@sa bit = 1
,@SUSER_NAME sysname = SUSER_SNAME()
,@SkipDBCC bit = 0
,@SkipTrace bit = 0
,@SkipXPRegRead bit = 0
,@SkipXPFixedDrives bit = 0
,@SkipXPCMDShell bit = 0
,@SkipMaster bit = 0
,@SkipMSDB bit = 0
,@SkipModel bit = 0
,@SkipTempDB bit = 0
,@SkipValidateLogins bit = 0;

DECLARE
@db_perms table
(
database_name sysname,
permission_name sysname
);

INSERT
@db_perms
(
database_name,
permission_name
)
SELECT
database_name =
DB_NAME(d.database_id),
fmp.permission_name
FROM sys.databases AS d
CROSS APPLY fn_my_permissions(d.name, 'DATABASE') AS fmp
WHERE fmp.permission_name = N'SELECT' /*Databases where we don't have read permissions*/

/* End of declarations for First Responder Kit consistency check:*/
;

/*Starting permissions checks here, but only if we're not a sysadmin*/
IF
(
SELECT
sa =
ISNULL
(
IS_SRVROLEMEMBER(N'sysadmin'),
0
)
) = 0
BEGIN
IF @Debug IN (1, 2) RAISERROR('User not SA, checking permissions', 0, 1) WITH NOWAIT;

SET @sa = 0; /*Setting this to 0 to skip DBCC COMMANDS*/

IF NOT EXISTS
(
SELECT
1/0
FROM sys.fn_my_permissions(NULL, NULL) AS fmp
WHERE fmp.permission_name = N'VIEW SERVER STATE'
)
BEGIN
RAISERROR('The user %s does not have VIEW SERVER STATE permissions.', 0, 11, @SUSER_NAME) WITH NOWAIT;
RETURN;
END; /*If we don't have this, we can't do anything at all.*/

IF NOT EXISTS
(
SELECT
1/0
FROM fn_my_permissions(N'sys.traces', N'OBJECT') AS fmp
WHERE fmp.permission_name = N'ALTER'
)
BEGIN
SET @SkipTrace = 1;
END; /*We need this permission to execute trace stuff, apparently*/

IF NOT EXISTS
(
SELECT
1/0
FROM fn_my_permissions(N'xp_regread', N'OBJECT') AS fmp
WHERE fmp.permission_name = N'EXECUTE'
)
BEGIN
SET @SkipXPRegRead = 1;
END; /*Need execute on xp_regread*/

IF NOT EXISTS
(
SELECT
1/0
FROM fn_my_permissions(N'xp_fixeddrives', N'OBJECT') AS fmp
WHERE fmp.permission_name = N'EXECUTE'
)
BEGIN
SET @SkipXPFixedDrives = 1;
END; /*Need execute on xp_fixeddrives*/

IF NOT EXISTS
(
SELECT
1/0
FROM fn_my_permissions(N'xp_cmdshell', N'OBJECT') AS fmp
WHERE fmp.permission_name = N'EXECUTE'
)
BEGIN
SET @SkipXPCMDShell = 1;
END; /*Need execute on xp_cmdshell*/

IF NOT EXISTS
(
SELECT
1/0
FROM fn_my_permissions(N'sp_validatelogins', N'OBJECT') AS fmp
WHERE fmp.permission_name = N'EXECUTE'
)
BEGIN
SET @SkipValidateLogins = 1;
END; /*Need execute on sp_validatelogins*/

END;

SET @crlf = NCHAR(13) + NCHAR(10);
SET @ResultText = 'sp_Blitz Results: ' + @crlf;

Expand Down Expand Up @@ -331,6 +449,66 @@ AS
OR LOWER(d.name) IN ('dbatools', 'dbadmin', 'dbmaintenance'))
OPTION(RECOMPILE);

/*Skip checks for database where we don't have read permissions*/
INSERT INTO
#SkipChecks
(
DatabaseName
)
SELECT
DB_NAME(d.database_id)
FROM sys.databases AS d
WHERE NOT EXISTS
(
SELECT
1/0
FROM @db_perms AS dp
WHERE dp.database_name = DB_NAME(d.database_id)
);

/*Skip individial checks where we don't have permissions*/
INSERT #SkipChecks (DatabaseName, CheckID, ServerName)
SELECT
v.*
FROM (VALUES(NULL, 29, NULL)) AS v (DatabaseName, CheckID, ServerName) /*Looks for user tables in model*/
WHERE NOT EXISTS (SELECT 1/0 FROM @db_perms AS dp WHERE dp.database_name = 'model');

INSERT #SkipChecks (DatabaseName, CheckID, ServerName)
SELECT
v.*
FROM (VALUES(NULL, 68, NULL)) AS v (DatabaseName, CheckID, ServerName) /*DBCC command*/
WHERE @sa = 0;

INSERT #SkipChecks (DatabaseName, CheckID, ServerName)
SELECT
v.*
FROM (VALUES(NULL, 69, NULL)) AS v (DatabaseName, CheckID, ServerName) /*DBCC command*/
WHERE @sa = 0;

INSERT #SkipChecks (DatabaseName, CheckID, ServerName)
SELECT
v.*
FROM (VALUES(NULL, 92, NULL)) AS v (DatabaseName, CheckID, ServerName) /*xp_fixeddrives*/
WHERE @SkipXPFixedDrives = 1;

INSERT #SkipChecks (DatabaseName, CheckID, ServerName)
SELECT
v.*
FROM (VALUES(NULL, 211, NULL)) AS v (DatabaseName, CheckID, ServerName) /*xp_regread*/
WHERE @SkipXPRegRead = 1;

INSERT #SkipChecks (DatabaseName, CheckID, ServerName)
SELECT
v.*
FROM (VALUES(NULL, 212, NULL)) AS v (DatabaseName, CheckID, ServerName) /*xp_regread*/
WHERE @SkipXPCMDShell = 1;

INSERT #SkipChecks (DatabaseName, CheckID, ServerName)
SELECT
v.*
FROM (VALUES(NULL, 2301, NULL)) AS v (DatabaseName, CheckID, ServerName) /*sp_validatelogins*/
WHERE @SkipValidateLogins = 1

IF(OBJECT_ID('tempdb..#InvalidLogins') IS NOT NULL)
BEGIN
EXEC sp_executesql N'DROP TABLE #InvalidLogins;';
Expand Down Expand Up @@ -372,7 +550,8 @@ AS
SELECT @IsWindowsOperatingSystem = 1 ;
END;

IF NOT EXISTS ( SELECT 1

IF NOT EXISTS ( SELECT 1
FROM #SkipChecks
WHERE DatabaseName IS NULL AND CheckID = 106 )
AND (select convert(int,value_in_use) from sys.configurations where name = 'default trace enabled' ) = 1
Expand Down Expand Up @@ -4158,53 +4337,56 @@ AS

/* First, let's check that there aren't any issues with the trace files */
BEGIN TRY

INSERT INTO #fnTraceGettable
( TextData ,
DatabaseName ,
EventClass ,
Severity ,
StartTime ,
EndTime ,
Duration ,
NTUserName ,
NTDomainName ,
HostName ,
ApplicationName ,
LoginName ,
DBUserName
)
SELECT TOP 20000
CONVERT(NVARCHAR(4000),t.TextData) ,
t.DatabaseName ,
t.EventClass ,
t.Severity ,
t.StartTime ,
t.EndTime ,
t.Duration ,
t.NTUserName ,
t.NTDomainName ,
t.HostName ,
t.ApplicationName ,
t.LoginName ,
t.DBUserName
FROM sys.fn_trace_gettable(@base_tracefilename, DEFAULT) t
WHERE
(
t.EventClass = 22
AND t.Severity >= 17
AND t.StartTime > DATEADD(dd, -30, GETDATE())
)
OR
(
t.EventClass IN (92, 93)
AND t.StartTime > DATEADD(dd, -30, GETDATE())
AND t.Duration > 15000000
)
OR
(
t.EventClass IN (94, 95, 116)
)

IF @SkipTrace = 0
BEGIN
INSERT INTO #fnTraceGettable
( TextData ,
DatabaseName ,
EventClass ,
Severity ,
StartTime ,
EndTime ,
Duration ,
NTUserName ,
NTDomainName ,
HostName ,
ApplicationName ,
LoginName ,
DBUserName
)
SELECT TOP 20000
CONVERT(NVARCHAR(4000),t.TextData) ,
t.DatabaseName ,
t.EventClass ,
t.Severity ,
t.StartTime ,
t.EndTime ,
t.Duration ,
t.NTUserName ,
t.NTDomainName ,
t.HostName ,
t.ApplicationName ,
t.LoginName ,
t.DBUserName
FROM sys.fn_trace_gettable(@base_tracefilename, DEFAULT) t
WHERE
(
t.EventClass = 22
AND t.Severity >= 17
AND t.StartTime > DATEADD(dd, -30, GETDATE())
)
OR
(
t.EventClass IN (92, 93)
AND t.StartTime > DATEADD(dd, -30, GETDATE())
AND t.Duration > 15000000
)
OR
(
t.EventClass IN (94, 95, 116)
)
END;

SET @TraceFileIssue = 0

Expand Down Expand Up @@ -6579,10 +6761,10 @@ IF @ProductVersionMajor >= 10
DatabaseName
FROM #SkipChecks
WHERE CheckID IS NULL OR CheckID = 19)
AND is_published = 1
AND (is_published = 1
OR is_subscribed = 1
OR is_merge_published = 1
OR is_distributor = 1;
OR is_distributor = 1);

/* Method B: check subscribers for MSreplication_objects tables */
EXEC dbo.sp_MSforeachdb 'USE [?]; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
Expand Down
2 changes: 1 addition & 1 deletion sp_BlitzAnalysis.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ AS
SET NOCOUNT ON;
SET STATISTICS XML OFF;

SELECT @Version = '8.15', @VersionDate = '20230613';
SELECT @Version = '8.16', @VersionDate = '20230820';

IF(@VersionCheckMode = 1)
BEGIN
Expand Down
2 changes: 1 addition & 1 deletion sp_BlitzBackups.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ AS
SET STATISTICS XML OFF;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

SELECT @Version = '8.15', @VersionDate = '20230613';
SELECT @Version = '8.16', @VersionDate = '20230820';

IF(@VersionCheckMode = 1)
BEGIN
Expand Down
Loading

0 comments on commit 49d64cb

Please sign in to comment.