From 8669cd6e93077148d49623a78c3f9b2f2f081ac2 Mon Sep 17 00:00:00 2001 From: Chrissy LeMaire Date: Sun, 17 Nov 2024 19:37:32 +0100 Subject: [PATCH] v2.1.28 --- .../SQLServerDiagnosticQueries_2016SP2.sql | 7 +- .../SQLServerDiagnosticQueries_2017.sql | 5 +- .../SQLServerDiagnosticQueries_2019.sql | 5 +- .../SQLServerDiagnosticQueries_2022.sql | 6 +- bin/maintenancesolution/CommandExecute.sql | 2 +- bin/maintenancesolution/DatabaseBackup.sql | 72 +++------------- .../DatabaseIntegrityCheck.sql | 4 +- bin/maintenancesolution/IndexOptimize.sql | 4 +- .../MaintenanceSolution.sql | 84 ++++--------------- dbatools.psd1 | 2 +- 10 files changed, 50 insertions(+), 141 deletions(-) diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2016SP2.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2016SP2.sql index e45502a9fe..a8cb845ebe 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2016SP2.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2016SP2.sql @@ -1,7 +1,7 @@ -- SQL Server 2016 SP2 Diagnostic Information Queries -- Glenn Berry --- Last Modified: November 1, 2024 +-- Last Modified: November 13, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -94,6 +94,8 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 13.0.6435.1 SP3 + GDR 10/10/2023 https://support.microsoft.com/en-us/topic/kb5029186-description-of-the-security-update-for-sql-server-2016-sp3-gdr-october-10-2023-618b034a-d575-48e0-804a-7b481ba2e600 -- 13.0.6441.1 SP3 + GDR 7/9/2024 https://support.microsoft.com/en-us/topic/kb5040946-description-of-the-security-update-for-sql-server-2016-sp3-gdr-july-9-2024-e943f6a8-7a97-41b4-804c-c52ca775f5dd -- 13.0.6445.1 SP3 + GDR 9/10/2024 https://support.microsoft.com/en-us/topic/kb5042207-description-of-the-security-update-for-sql-server-2016-sp3-gdr-september-10-2024-e27a41df-009d-4a50-85e7-dc8f06b9a5a5 +-- 13.0.6450.1 SP3 + GDR 10/8/2024 https://support.microsoft.com/en-us/topic/kb5046063-description-of-the-security-update-for-sql-server-2016-sp3-gdr-october-8-2024-87f6091b-a0c0-48e7-8de4-b10381559ba7 +-- 13.0.6455.2 SP3 + GDR 11/12/2024 https://support.microsoft.com/en-us/topic/kb5046855-description-of-the-security-update-for-sql-server-2016-sp3-gdr-november-12-2024-736b0a32-912d-4ea5-baf8-50d046cbfa1a -- Azure Connect Pack Builds -- 13.0.7000.253 Azure Connect Pack 5/19/2022 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2016/servicepack3-azureconnect @@ -102,6 +104,9 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 13.0.7029.3 Azure Connect Pack + GDR 10/10/2023 https://support.microsoft.com/en-us/topic/kb5029187-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-october-10-2023-e5541468-f243-4000-872c-ac782cfad99f -- 13.0.7037.1 Azure Connect Pack + GDR 7/9/2024 https://support.microsoft.com/en-us/topic/kb5040944-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-july-9-2024-72b636c9-0619-4c44-b263-f3d7478bcd75 -- 13.0.7040.1 Azure Connect Pack + GDR 9/10/2024 https://support.microsoft.com/en-us/topic/kb5042207-description-of-the-security-update-for-sql-server-2016-sp3-gdr-september-10-2024-e27a41df-009d-4a50-85e7-dc8f06b9a5a5 +-- 13.0.7045.2 Azure Connect Pack + GDR 10/8/2024 https://support.microsoft.com/en-us/topic/kb5046062-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-october-8-2024-fb7d9289-bbef-4d1f-bd71-fb3e036d81ae +-- 13.0.7050.2 Azure Connect Pack + GDR 11/12/2024 https://support.microsoft.com/en-us/topic/kb5046856-description-of-the-security-update-for-sql-server-2016-sp3-azure-connect-feature-pack-november-12-2024-b180cac0-187e-48eb-b6c6-3d48d0a00902 + -- How to determine the version, edition and update level of SQL Server and its components -- https://bit.ly/2oAjKgW diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2017.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2017.sql index bfd64e3147..3b0e85aed6 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2017.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2017.sql @@ -1,7 +1,7 @@ -- SQL Server 2017 Diagnostic Information Queries -- Glenn Berry --- Last Modified: November 1, 2024 +-- Last Modified: November 13, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -108,6 +108,9 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 14.0.3465.1 CU31 + GDR 10/10/2023 https://support.microsoft.com/en-us/topic/kb5029376-description-of-the-security-update-for-sql-server-2017-cu31-october-10-2023-ce23ddf7-b79e-4ba7-ba9d-2679f23a1ad8 -- 14.0.3471.2 CU31 + GDR 7/9/2024 https://support.microsoft.com/en-us/topic/kb5040940-description-of-the-security-update-for-sql-server-2017-cu31-july-9-2024-bff7ab26-e882-4419-aebb-30356125f5c9 -- 14.0.3475.1 CU31 + GDR 9/10/2024 https://support.microsoft.com/en-us/topic/kb5042215-description-of-the-security-update-for-sql-server-2017-cu31-september-10-2024-55bba26f-548d-466c-9c48-edfb51a53a8a +-- 14.0.3480.1 CU31 + GDR 10/8/2024 https://support.microsoft.com/en-us/topic/kb5046061-description-of-the-security-update-for-sql-server-2017-cu31-october-8-2024-af669e75-bc43-4679-bfbe-e153e679dd2f +-- 14.0.3485.1 CU31 + GDR 11/12/2024 https://support.microsoft.com/en-us/topic/kb5046858-description-of-the-security-update-for-sql-server-2017-cu31-november-12-2024-2984d3a5-0683-4f9b-9e6a-3888e67bd859 + -- How to determine the version, edition and update level of SQL Server and its components -- https://bit.ly/2oAjKgW diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2019.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2019.sql index 980f2092e0..3a9fdfe82d 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2019.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2019.sql @@ -1,7 +1,7 @@ -- SQL Server 2019 Diagnostic Information Queries -- Glenn Berry --- Last Modified: November 1, 2024 +-- Last Modified: November 13, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -105,7 +105,8 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 15.0.4382.1 CU27 + GDR 7/9/2024 https://support.microsoft.com/en-us/topic/kb5040948-description-of-the-security-update-for-sql-server-2019-cu27-july-9-2024-6447dc00-9f1b-484c-9d3d-9e1f1b9f915c -- 15.0.4385.2 CU28 8/1/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate28 -- 15.0.4390.2 CU28 + GDR 9/10/2024 https://support.microsoft.com/en-us/topic/kb5042749-description-of-the-security-update-for-sql-server-2019-cu28-september-10-2024-17402ce5-07d3-4e30-9037-9ef997104f34 --- 15.0.4405.4 CU29 11/1/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate29 +-- 15.0.4405.4 CU29 10/31/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate29 +-- 15.0.4410.1 CU29 + GDR 11/12/2024 https://support.microsoft.com/en-us/topic/kb5046860-description-of-the-security-update-for-sql-server-2019-cu29-november-12-2024-4bddde28-482c-4628-a6e2-2d4f542088b7 -- How to determine the version, edition and update level of SQL Server and its components diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2022.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2022.sql index 380a83b894..958d6a26ac 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2022.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2022.sql @@ -1,7 +1,7 @@ -- SQL Server 2022 Diagnostic Information Queries -- Glenn Berry --- Last Modified: November 1, 2024 +-- Last Modified: November 15, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -84,6 +84,10 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 16.0.4135.4 CU14 7/23/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate14 -- 16.0.4140.3 CU14 + GDR 9/10/2024 https://support.microsoft.com/en-us/topic/kb5042578-description-of-the-security-update-for-sql-server-2022-cu14-september-10-2024-560e6e4c-1f49-4c18-9eb7-054e9fdee3c7 -- 16.0.4145.4 CU15 9/25/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate15 +-- 16.0.4150.1 CU15 + GDR 10/8/2024 https://support.microsoft.com/en-us/topic/kb5046059-description-of-the-security-update-for-sql-server-2022-cu15-october-8-2024-b592d86f-3351-4f9f-9c80-ef495a0137c1 +-- 16.0.4155.4 CU15 + GDR 11/12/2024 https://support.microsoft.com/en-us/topic/kb5046862-description-of-the-security-update-for-sql-server-2022-cu15-november-12-2024-ab9f3a55-8264-44e9-9a40-0b32bcd83df0 +-- 16.0.4165.4 CU16 11/14/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate16 + -- What's new in SQL Server 2022 (16.x) -- https://bit.ly/3MJEjR1 diff --git a/bin/maintenancesolution/CommandExecute.sql b/bin/maintenancesolution/CommandExecute.sql index 8654475d88..2246d69c47 100644 --- a/bin/maintenancesolution/CommandExecute.sql +++ b/bin/maintenancesolution/CommandExecute.sql @@ -36,7 +36,7 @@ BEGIN --// Source: https://ola.hallengren.com //-- --// License: https://ola.hallengren.com/license.html //-- --// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //-- - --// Version: 2024-11-14 14:03:14 //-- + --// Version: 2022-12-03 17:23:44 //-- ---------------------------------------------------------------------------------------------------- SET NOCOUNT ON diff --git a/bin/maintenancesolution/DatabaseBackup.sql b/bin/maintenancesolution/DatabaseBackup.sql index f0f859f52f..d804328186 100644 --- a/bin/maintenancesolution/DatabaseBackup.sql +++ b/bin/maintenancesolution/DatabaseBackup.sql @@ -16,7 +16,6 @@ ALTER PROCEDURE [dbo].[DatabaseBackup] @CleanupTime int = NULL, @CleanupMode nvarchar(max) = 'AFTER_BACKUP', @Compress nvarchar(max) = NULL, -@CompressionAlgorithm nvarchar(max) = NULL, @CopyOnly nvarchar(max) = 'N', @ChangeBackupType nvarchar(max) = 'N', @BackupSoftware nvarchar(max) = NULL, @@ -67,7 +66,6 @@ ALTER PROCEDURE [dbo].[DatabaseBackup] @ObjectLevelRecoveryMap nvarchar(max) = 'N', @ExcludeLogShippedFromLogBackup nvarchar(max) = 'Y', @DirectoryCheck nvarchar(max) = 'Y', -@BackupOptions nvarchar(max) = NULL, @StringDelimiter nvarchar(max) = ',', @DatabaseOrder nvarchar(max) = NULL, @DatabasesInParallel nvarchar(max) = 'N', @@ -82,7 +80,7 @@ BEGIN --// Source: https://ola.hallengren.com //-- --// License: https://ola.hallengren.com/license.html //-- --// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //-- - --// Version: 2024-11-14 14:03:14 //-- + --// Version: 2022-12-03 17:23:44 //-- ---------------------------------------------------------------------------------------------------- SET NOCOUNT ON @@ -281,7 +279,6 @@ BEGIN SET @Parameters += ', @CleanupTime = ' + ISNULL(CAST(@CleanupTime AS nvarchar),'NULL') SET @Parameters += ', @CleanupMode = ' + ISNULL('''' + REPLACE(@CleanupMode,'''','''''') + '''','NULL') SET @Parameters += ', @Compress = ' + ISNULL('''' + REPLACE(@Compress,'''','''''') + '''','NULL') - SET @Parameters += ', @CompressionAlgorithm = ' + ISNULL('''' + REPLACE(@CompressionAlgorithm,'''','''''') + '''','NULL') SET @Parameters += ', @CopyOnly = ' + ISNULL('''' + REPLACE(@CopyOnly,'''','''''') + '''','NULL') SET @Parameters += ', @ChangeBackupType = ' + ISNULL('''' + REPLACE(@ChangeBackupType,'''','''''') + '''','NULL') SET @Parameters += ', @BackupSoftware = ' + ISNULL('''' + REPLACE(@BackupSoftware,'''','''''') + '''','NULL') @@ -553,7 +550,7 @@ BEGIN GROUP BY tmpDatabases.DatabaseName) SelectedDatabases2 ON tmpDatabases.DatabaseName = SelectedDatabases2.DatabaseName - IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DATALENGTH(DatabaseName) = 0)) + IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DatabaseName = '')) BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Databases is not supported.', 16, 1 @@ -674,7 +671,7 @@ BEGIN SELECT @ErrorMessage = @ErrorMessage + QUOTENAME(DatabaseName) + ', ' FROM @tmpDatabases WHERE Selected = 1 - AND DATALENGTH(DatabaseNameFS) = 0 + AND DatabaseNameFS = '' ORDER BY DatabaseName ASC IF @@ROWCOUNT > 0 BEGIN @@ -687,7 +684,7 @@ BEGIN FROM @tmpDatabases WHERE UPPER(DatabaseNameFS) IN(SELECT UPPER(DatabaseNameFS) FROM @tmpDatabases GROUP BY UPPER(DatabaseNameFS) HAVING COUNT(*) > 1) AND UPPER(DatabaseNameFS) IN(SELECT UPPER(DatabaseNameFS) FROM @tmpDatabases WHERE Selected = 1) - AND DATALENGTH(DatabaseNameFS) > 0 + AND DatabaseNameFS <> '' ORDER BY DatabaseName ASC OPTION (RECOMPILE) IF @@ROWCOUNT > 0 @@ -964,7 +961,7 @@ BEGIN --// Check URLs //-- ---------------------------------------------------------------------------------------------------- - IF EXISTS(SELECT * FROM @URLs WHERE Mirror = 0 AND NOT (DirectoryPath LIKE 'https://%/%' OR DirectoryPath LIKE 's3://%/%')) + IF EXISTS(SELECT * FROM @URLs WHERE Mirror = 0 AND DirectoryPath NOT LIKE 'https://%/%') BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @URL is not supported.', 16, 1 @@ -984,7 +981,7 @@ BEGIN ---------------------------------------------------------------------------------------------------- - IF EXISTS(SELECT * FROM @URLs WHERE Mirror = 1 AND NOT (DirectoryPath LIKE 'https://%/%' OR DirectoryPath LIKE 's3://%/%')) + IF EXISTS(SELECT * FROM @URLs WHERE Mirror = 1 AND DirectoryPath NOT LIKE 'https://%/%') BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @MirrorURL is not supported.', 16, 1 @@ -1066,16 +1063,6 @@ BEGIN WHEN @BackupSoftware IS NOT NULL AND @CompressionLevel = 0 THEN 'N' END END - ---------------------------------------------------------------------------------------------------- - --// Get default compression algorithm //-- - ---------------------------------------------------------------------------------------------------- - - IF @CompressionAlgorithm IS NULL AND @BackupSoftware IS NULL AND @Version >= 16 - BEGIN - SELECT @CompressionAlgorithm = CASE WHEN @BackupSoftware IS NULL AND EXISTS(SELECT * FROM sys.configurations WHERE name = 'backup compression algorithm' AND value_in_use = 1) THEN 'MS_XPRESS' - WHEN @BackupSoftware IS NULL AND EXISTS(SELECT * FROM sys.configurations WHERE name = 'backup compression algorithm' AND value_in_use = 2) THEN 'QAT_DEFLATE' END - END - ---------------------------------------------------------------------------------------------------- --// Check input parameters //-- ---------------------------------------------------------------------------------------------------- @@ -1194,32 +1181,6 @@ BEGIN ---------------------------------------------------------------------------------------------------- - IF @CompressionAlgorithm NOT IN ('MS_XPRESS','QAT_DEFLATE') - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @CompressionAlgorithm is not supported. The allowed values are MS_XPRESS and QAT_DEFLATE.', 16, 1 - END - - IF @CompressionAlgorithm IS NOT NULL AND NOT (@Version >= 16) - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @CompressionAlgorithm is not supported. Specifying the compression algorithm is only supported in SQL Server 2022 and later.', 16, 2 - END - - IF @CompressionAlgorithm = 'QAT_DEFLATE' AND NOT (SERVERPROPERTY('EngineEdition') IN(2, 3)) - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @CompressionAlgorithm is not supported. Setting the compression algorithm to QAT_DEFLATE is only supported in Standard and Enterprise Edition.', 16, 3 - END - - IF @CompressionAlgorithm IS NOT NULL AND @BackupSoftware IS NOT NULL - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @CompressionAlgorithm is not supported. Setting the compression algorithm is only supported with SQL Server native backup', 16, 4 - END - - ---------------------------------------------------------------------------------------------------- - IF @CopyOnly NOT IN ('Y','N') OR @CopyOnly IS NULL BEGIN INSERT INTO @Errors ([Message], Severity, [State]) @@ -1334,7 +1295,7 @@ BEGIN ---------------------------------------------------------------------------------------------------- - IF @MaxTransferSize < 65536 OR @MaxTransferSize > 20971520 + IF @MaxTransferSize < 65536 OR @MaxTransferSize > 4194304 BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @MaxTransferSize is not supported.', 16, 1 @@ -1420,13 +1381,7 @@ BEGIN SELECT 'The value for the parameter @NumberOfFiles is not supported.', 16, 9 END - IF @NumberOfFiles > 32 AND @URL LIKE 's3%' AND @MirrorURL LIKE 's3%' - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @NumberOfFiles is not supported. The maximum number of files when performing mirrored backups to S3 storage is 32.', 16, 10 - END - - ---------------------------------------------------------------------------------------------------- + ---------------------------------------------------------------------------------------------------- IF @MinBackupSizeForMultipleFiles <= 0 BEGIN @@ -1578,7 +1533,7 @@ BEGIN SELECT 'The value for the parameter @Encrypt is not supported.', 16, 1 END - IF @Encrypt = 'Y' AND @BackupSoftware IS NULL AND NOT (@Version >= 12 AND (SERVERPROPERTY('EngineEdition') IN(3, 8) OR SERVERPROPERTY('EditionID') IN(-1534726760, 284895786))) + IF @Encrypt = 'Y' AND @BackupSoftware IS NULL AND NOT (@Version >= 12 AND (SERVERPROPERTY('EngineEdition') = 3) OR SERVERPROPERTY('EditionID') IN(-1534726760, 284895786)) BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Encrypt is not supported.', 16, 2 @@ -1783,7 +1738,7 @@ BEGIN SELECT 'The value for the parameter @Credential is not supported.', 16, 2 END - IF @URL IS NOT NULL AND @Credential IS NULL AND NOT EXISTS(SELECT * FROM sys.credentials WHERE UPPER(credential_identity) IN('SHARED ACCESS SIGNATURE','MANAGED IDENTITY','S3 ACCESS KEY')) + IF @URL IS NOT NULL AND @Credential IS NULL AND NOT EXISTS(SELECT * FROM sys.credentials WHERE UPPER(credential_identity) = 'SHARED ACCESS SIGNATURE') BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Credential is not supported.', 16, 3 @@ -3577,11 +3532,6 @@ BEGIN SET @CurrentCommand += CASE WHEN @Compress = 'Y' AND (@CurrentIsEncrypted = 0 OR (@CurrentIsEncrypted = 1 AND ((@Version >= 13 AND @CurrentMaxTransferSize >= 65537) OR @Version >= 15.0404316 OR SERVERPROPERTY('EngineEdition') = 8))) THEN ', COMPRESSION' ELSE ', NO_COMPRESSION' END END - IF @Compress = 'Y' AND @CompressionAlgorithm IS NOT NULL - BEGIN - SET @CurrentCommand += ' (ALGORITHM = ' + @CompressionAlgorithm + ')' - END - IF @CurrentBackupType = 'DIFF' SET @CurrentCommand += ', DIFFERENTIAL' IF EXISTS(SELECT * FROM @CurrentFiles WHERE Mirror = 1) @@ -3597,7 +3547,6 @@ BEGIN IF @BufferCount IS NOT NULL SET @CurrentCommand += ', BUFFERCOUNT = ' + CAST(@BufferCount AS nvarchar) IF @CurrentMaxTransferSize IS NOT NULL SET @CurrentCommand += ', MAXTRANSFERSIZE = ' + CAST(@CurrentMaxTransferSize AS nvarchar) IF @Description IS NOT NULL SET @CurrentCommand += ', DESCRIPTION = N''' + REPLACE(@Description,'''','''''') + '''' - IF @BackupOptions IS NOT NULL SET @CurrentCommand += ', BACKUP_OPTIONS = N''' + REPLACE(@BackupOptions,'''','''''') + '''' IF @Encrypt = 'Y' SET @CurrentCommand += ', ENCRYPTION (ALGORITHM = ' + UPPER(@EncryptionAlgorithm) + ', ' IF @Encrypt = 'Y' AND @ServerCertificate IS NOT NULL SET @CurrentCommand += 'SERVER CERTIFICATE = ' + QUOTENAME(@ServerCertificate) IF @Encrypt = 'Y' AND @ServerAsymmetricKey IS NOT NULL SET @CurrentCommand += 'SERVER ASYMMETRIC KEY = ' + QUOTENAME(@ServerAsymmetricKey) @@ -3837,7 +3786,6 @@ BEGIN SET @CurrentCommand += ' WITH ' IF @CheckSum = 'Y' SET @CurrentCommand += 'CHECKSUM' IF @CheckSum = 'N' SET @CurrentCommand += 'NO_CHECKSUM' - IF @BackupOptions IS NOT NULL SET @CurrentCommand += ', RESTORE_OPTIONS = N''' + REPLACE(@BackupOptions,'''','''''') + '''' IF @URL IS NOT NULL AND @Credential IS NOT NULL SET @CurrentCommand += ', CREDENTIAL = N''' + REPLACE(@Credential,'''','''''') + '''' END diff --git a/bin/maintenancesolution/DatabaseIntegrityCheck.sql b/bin/maintenancesolution/DatabaseIntegrityCheck.sql index e274eb282f..daaca94748 100644 --- a/bin/maintenancesolution/DatabaseIntegrityCheck.sql +++ b/bin/maintenancesolution/DatabaseIntegrityCheck.sql @@ -39,7 +39,7 @@ BEGIN --// Source: https://ola.hallengren.com //-- --// License: https://ola.hallengren.com/license.html //-- --// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //-- - --// Version: 2024-11-14 14:03:14 //-- + --// Version: 2022-12-03 17:23:44 //-- ---------------------------------------------------------------------------------------------------- SET NOCOUNT ON @@ -429,7 +429,7 @@ BEGIN GROUP BY tmpDatabases.DatabaseName) SelectedDatabases2 ON tmpDatabases.DatabaseName = SelectedDatabases2.DatabaseName - IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DATALENGTH(DatabaseName) = 0)) + IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DatabaseName = '')) BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Databases is not supported.', 16, 1 diff --git a/bin/maintenancesolution/IndexOptimize.sql b/bin/maintenancesolution/IndexOptimize.sql index f64cd21323..2d49384ade 100644 --- a/bin/maintenancesolution/IndexOptimize.sql +++ b/bin/maintenancesolution/IndexOptimize.sql @@ -53,7 +53,7 @@ BEGIN --// Source: https://ola.hallengren.com //-- --// License: https://ola.hallengren.com/license.html //-- --// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //-- - --// Version: 2024-11-14 14:03:14 //-- + --// Version: 2022-12-03 17:23:44 //-- ---------------------------------------------------------------------------------------------------- SET NOCOUNT ON @@ -521,7 +521,7 @@ BEGIN GROUP BY tmpDatabases.DatabaseName) SelectedDatabases2 ON tmpDatabases.DatabaseName = SelectedDatabases2.DatabaseName - IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DATALENGTH(DatabaseName) = 0)) + IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DatabaseName = '')) BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Databases is not supported.', 16, 1 diff --git a/bin/maintenancesolution/MaintenanceSolution.sql b/bin/maintenancesolution/MaintenanceSolution.sql index 1bb476b84d..59dd177350 100644 --- a/bin/maintenancesolution/MaintenanceSolution.sql +++ b/bin/maintenancesolution/MaintenanceSolution.sql @@ -10,7 +10,7 @@ License: https://ola.hallengren.com/license.html GitHub: https://github.com/olahallengren/sql-server-maintenance-solution -Version: 2024-11-14 14:03:14 +Version: 2022-12-03 17:23:44 You can contact me by e-mail at ola@hallengren.com. @@ -123,7 +123,7 @@ BEGIN --// Source: https://ola.hallengren.com //-- --// License: https://ola.hallengren.com/license.html //-- --// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //-- - --// Version: 2024-11-14 14:03:14 //-- + --// Version: 2022-12-03 17:23:44 //-- ---------------------------------------------------------------------------------------------------- SET NOCOUNT ON @@ -395,7 +395,6 @@ ALTER PROCEDURE [dbo].[DatabaseBackup] @CleanupTime int = NULL, @CleanupMode nvarchar(max) = 'AFTER_BACKUP', @Compress nvarchar(max) = NULL, -@CompressionAlgorithm nvarchar(max) = NULL, @CopyOnly nvarchar(max) = 'N', @ChangeBackupType nvarchar(max) = 'N', @BackupSoftware nvarchar(max) = NULL, @@ -446,7 +445,6 @@ ALTER PROCEDURE [dbo].[DatabaseBackup] @ObjectLevelRecoveryMap nvarchar(max) = 'N', @ExcludeLogShippedFromLogBackup nvarchar(max) = 'Y', @DirectoryCheck nvarchar(max) = 'Y', -@BackupOptions nvarchar(max) = NULL, @StringDelimiter nvarchar(max) = ',', @DatabaseOrder nvarchar(max) = NULL, @DatabasesInParallel nvarchar(max) = 'N', @@ -461,7 +459,7 @@ BEGIN --// Source: https://ola.hallengren.com //-- --// License: https://ola.hallengren.com/license.html //-- --// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //-- - --// Version: 2024-11-14 14:03:14 //-- + --// Version: 2022-12-03 17:23:44 //-- ---------------------------------------------------------------------------------------------------- SET NOCOUNT ON @@ -660,7 +658,6 @@ BEGIN SET @Parameters += ', @CleanupTime = ' + ISNULL(CAST(@CleanupTime AS nvarchar),'NULL') SET @Parameters += ', @CleanupMode = ' + ISNULL('''' + REPLACE(@CleanupMode,'''','''''') + '''','NULL') SET @Parameters += ', @Compress = ' + ISNULL('''' + REPLACE(@Compress,'''','''''') + '''','NULL') - SET @Parameters += ', @CompressionAlgorithm = ' + ISNULL('''' + REPLACE(@CompressionAlgorithm,'''','''''') + '''','NULL') SET @Parameters += ', @CopyOnly = ' + ISNULL('''' + REPLACE(@CopyOnly,'''','''''') + '''','NULL') SET @Parameters += ', @ChangeBackupType = ' + ISNULL('''' + REPLACE(@ChangeBackupType,'''','''''') + '''','NULL') SET @Parameters += ', @BackupSoftware = ' + ISNULL('''' + REPLACE(@BackupSoftware,'''','''''') + '''','NULL') @@ -932,7 +929,7 @@ BEGIN GROUP BY tmpDatabases.DatabaseName) SelectedDatabases2 ON tmpDatabases.DatabaseName = SelectedDatabases2.DatabaseName - IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DATALENGTH(DatabaseName) = 0)) + IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DatabaseName = '')) BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Databases is not supported.', 16, 1 @@ -1053,7 +1050,7 @@ BEGIN SELECT @ErrorMessage = @ErrorMessage + QUOTENAME(DatabaseName) + ', ' FROM @tmpDatabases WHERE Selected = 1 - AND DATALENGTH(DatabaseNameFS) = 0 + AND DatabaseNameFS = '' ORDER BY DatabaseName ASC IF @@ROWCOUNT > 0 BEGIN @@ -1066,7 +1063,7 @@ BEGIN FROM @tmpDatabases WHERE UPPER(DatabaseNameFS) IN(SELECT UPPER(DatabaseNameFS) FROM @tmpDatabases GROUP BY UPPER(DatabaseNameFS) HAVING COUNT(*) > 1) AND UPPER(DatabaseNameFS) IN(SELECT UPPER(DatabaseNameFS) FROM @tmpDatabases WHERE Selected = 1) - AND DATALENGTH(DatabaseNameFS) > 0 + AND DatabaseNameFS <> '' ORDER BY DatabaseName ASC OPTION (RECOMPILE) IF @@ROWCOUNT > 0 @@ -1343,7 +1340,7 @@ BEGIN --// Check URLs //-- ---------------------------------------------------------------------------------------------------- - IF EXISTS(SELECT * FROM @URLs WHERE Mirror = 0 AND NOT (DirectoryPath LIKE 'https://%/%' OR DirectoryPath LIKE 's3://%/%')) + IF EXISTS(SELECT * FROM @URLs WHERE Mirror = 0 AND DirectoryPath NOT LIKE 'https://%/%') BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @URL is not supported.', 16, 1 @@ -1363,7 +1360,7 @@ BEGIN ---------------------------------------------------------------------------------------------------- - IF EXISTS(SELECT * FROM @URLs WHERE Mirror = 1 AND NOT (DirectoryPath LIKE 'https://%/%' OR DirectoryPath LIKE 's3://%/%')) + IF EXISTS(SELECT * FROM @URLs WHERE Mirror = 1 AND DirectoryPath NOT LIKE 'https://%/%') BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @MirrorURL is not supported.', 16, 1 @@ -1445,16 +1442,6 @@ BEGIN WHEN @BackupSoftware IS NOT NULL AND @CompressionLevel = 0 THEN 'N' END END - ---------------------------------------------------------------------------------------------------- - --// Get default compression algorithm //-- - ---------------------------------------------------------------------------------------------------- - - IF @CompressionAlgorithm IS NULL AND @BackupSoftware IS NULL AND @Version >= 16 - BEGIN - SELECT @CompressionAlgorithm = CASE WHEN @BackupSoftware IS NULL AND EXISTS(SELECT * FROM sys.configurations WHERE name = 'backup compression algorithm' AND value_in_use = 1) THEN 'MS_XPRESS' - WHEN @BackupSoftware IS NULL AND EXISTS(SELECT * FROM sys.configurations WHERE name = 'backup compression algorithm' AND value_in_use = 2) THEN 'QAT_DEFLATE' END - END - ---------------------------------------------------------------------------------------------------- --// Check input parameters //-- ---------------------------------------------------------------------------------------------------- @@ -1573,32 +1560,6 @@ BEGIN ---------------------------------------------------------------------------------------------------- - IF @CompressionAlgorithm NOT IN ('MS_XPRESS','QAT_DEFLATE') - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @CompressionAlgorithm is not supported. The allowed values are MS_XPRESS and QAT_DEFLATE.', 16, 1 - END - - IF @CompressionAlgorithm IS NOT NULL AND NOT (@Version >= 16) - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @CompressionAlgorithm is not supported. Specifying the compression algorithm is only supported in SQL Server 2022 and later.', 16, 2 - END - - IF @CompressionAlgorithm = 'QAT_DEFLATE' AND NOT (SERVERPROPERTY('EngineEdition') IN(2, 3)) - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @CompressionAlgorithm is not supported. Setting the compression algorithm to QAT_DEFLATE is only supported in Standard and Enterprise Edition.', 16, 3 - END - - IF @CompressionAlgorithm IS NOT NULL AND @BackupSoftware IS NOT NULL - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @CompressionAlgorithm is not supported. Setting the compression algorithm is only supported with SQL Server native backup', 16, 4 - END - - ---------------------------------------------------------------------------------------------------- - IF @CopyOnly NOT IN ('Y','N') OR @CopyOnly IS NULL BEGIN INSERT INTO @Errors ([Message], Severity, [State]) @@ -1713,7 +1674,7 @@ BEGIN ---------------------------------------------------------------------------------------------------- - IF @MaxTransferSize < 65536 OR @MaxTransferSize > 20971520 + IF @MaxTransferSize < 65536 OR @MaxTransferSize > 4194304 BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @MaxTransferSize is not supported.', 16, 1 @@ -1799,13 +1760,7 @@ BEGIN SELECT 'The value for the parameter @NumberOfFiles is not supported.', 16, 9 END - IF @NumberOfFiles > 32 AND @URL LIKE 's3%' AND @MirrorURL LIKE 's3%' - BEGIN - INSERT INTO @Errors ([Message], Severity, [State]) - SELECT 'The value for the parameter @NumberOfFiles is not supported. The maximum number of files when performing mirrored backups to S3 storage is 32.', 16, 10 - END - - ---------------------------------------------------------------------------------------------------- + ---------------------------------------------------------------------------------------------------- IF @MinBackupSizeForMultipleFiles <= 0 BEGIN @@ -1957,7 +1912,7 @@ BEGIN SELECT 'The value for the parameter @Encrypt is not supported.', 16, 1 END - IF @Encrypt = 'Y' AND @BackupSoftware IS NULL AND NOT (@Version >= 12 AND (SERVERPROPERTY('EngineEdition') IN(3, 8) OR SERVERPROPERTY('EditionID') IN(-1534726760, 284895786))) + IF @Encrypt = 'Y' AND @BackupSoftware IS NULL AND NOT (@Version >= 12 AND (SERVERPROPERTY('EngineEdition') = 3) OR SERVERPROPERTY('EditionID') IN(-1534726760, 284895786)) BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Encrypt is not supported.', 16, 2 @@ -2162,7 +2117,7 @@ BEGIN SELECT 'The value for the parameter @Credential is not supported.', 16, 2 END - IF @URL IS NOT NULL AND @Credential IS NULL AND NOT EXISTS(SELECT * FROM sys.credentials WHERE UPPER(credential_identity) IN('SHARED ACCESS SIGNATURE','MANAGED IDENTITY','S3 ACCESS KEY')) + IF @URL IS NOT NULL AND @Credential IS NULL AND NOT EXISTS(SELECT * FROM sys.credentials WHERE UPPER(credential_identity) = 'SHARED ACCESS SIGNATURE') BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Credential is not supported.', 16, 3 @@ -3956,11 +3911,6 @@ BEGIN SET @CurrentCommand += CASE WHEN @Compress = 'Y' AND (@CurrentIsEncrypted = 0 OR (@CurrentIsEncrypted = 1 AND ((@Version >= 13 AND @CurrentMaxTransferSize >= 65537) OR @Version >= 15.0404316 OR SERVERPROPERTY('EngineEdition') = 8))) THEN ', COMPRESSION' ELSE ', NO_COMPRESSION' END END - IF @Compress = 'Y' AND @CompressionAlgorithm IS NOT NULL - BEGIN - SET @CurrentCommand += ' (ALGORITHM = ' + @CompressionAlgorithm + ')' - END - IF @CurrentBackupType = 'DIFF' SET @CurrentCommand += ', DIFFERENTIAL' IF EXISTS(SELECT * FROM @CurrentFiles WHERE Mirror = 1) @@ -3976,7 +3926,6 @@ BEGIN IF @BufferCount IS NOT NULL SET @CurrentCommand += ', BUFFERCOUNT = ' + CAST(@BufferCount AS nvarchar) IF @CurrentMaxTransferSize IS NOT NULL SET @CurrentCommand += ', MAXTRANSFERSIZE = ' + CAST(@CurrentMaxTransferSize AS nvarchar) IF @Description IS NOT NULL SET @CurrentCommand += ', DESCRIPTION = N''' + REPLACE(@Description,'''','''''') + '''' - IF @BackupOptions IS NOT NULL SET @CurrentCommand += ', BACKUP_OPTIONS = N''' + REPLACE(@BackupOptions,'''','''''') + '''' IF @Encrypt = 'Y' SET @CurrentCommand += ', ENCRYPTION (ALGORITHM = ' + UPPER(@EncryptionAlgorithm) + ', ' IF @Encrypt = 'Y' AND @ServerCertificate IS NOT NULL SET @CurrentCommand += 'SERVER CERTIFICATE = ' + QUOTENAME(@ServerCertificate) IF @Encrypt = 'Y' AND @ServerAsymmetricKey IS NOT NULL SET @CurrentCommand += 'SERVER ASYMMETRIC KEY = ' + QUOTENAME(@ServerAsymmetricKey) @@ -4216,7 +4165,6 @@ BEGIN SET @CurrentCommand += ' WITH ' IF @CheckSum = 'Y' SET @CurrentCommand += 'CHECKSUM' IF @CheckSum = 'N' SET @CurrentCommand += 'NO_CHECKSUM' - IF @BackupOptions IS NOT NULL SET @CurrentCommand += ', RESTORE_OPTIONS = N''' + REPLACE(@BackupOptions,'''','''''') + '''' IF @URL IS NOT NULL AND @Credential IS NOT NULL SET @CurrentCommand += ', CREDENTIAL = N''' + REPLACE(@Credential,'''','''''') + '''' END @@ -4554,7 +4502,7 @@ BEGIN --// Source: https://ola.hallengren.com //-- --// License: https://ola.hallengren.com/license.html //-- --// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //-- - --// Version: 2024-11-14 14:03:14 //-- + --// Version: 2022-12-03 17:23:44 //-- ---------------------------------------------------------------------------------------------------- SET NOCOUNT ON @@ -4944,7 +4892,7 @@ BEGIN GROUP BY tmpDatabases.DatabaseName) SelectedDatabases2 ON tmpDatabases.DatabaseName = SelectedDatabases2.DatabaseName - IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DATALENGTH(DatabaseName) = 0)) + IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DatabaseName = '')) BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Databases is not supported.', 16, 1 @@ -6456,7 +6404,7 @@ BEGIN --// Source: https://ola.hallengren.com //-- --// License: https://ola.hallengren.com/license.html //-- --// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //-- - --// Version: 2024-11-14 14:03:14 //-- + --// Version: 2022-12-03 17:23:44 //-- ---------------------------------------------------------------------------------------------------- SET NOCOUNT ON @@ -6924,7 +6872,7 @@ BEGIN GROUP BY tmpDatabases.DatabaseName) SelectedDatabases2 ON tmpDatabases.DatabaseName = SelectedDatabases2.DatabaseName - IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DATALENGTH(DatabaseName) = 0)) + IF @Databases IS NOT NULL AND (NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DatabaseName = '')) BEGIN INSERT INTO @Errors ([Message], Severity, [State]) SELECT 'The value for the parameter @Databases is not supported.', 16, 1 diff --git a/dbatools.psd1 b/dbatools.psd1 index a1e7758c8a..ddb84d8a8c 100644 --- a/dbatools.psd1 +++ b/dbatools.psd1 @@ -11,7 +11,7 @@ RootModule = 'dbatools.psm1' # Version number of this module. - ModuleVersion = '2.1.27' + ModuleVersion = '2.1.28' # ID used to uniquely identify this module GUID = '9d139310-ce45-41ce-8e8b-d76335aa1789'