Skip to content

Commit af934ef

Browse files
Add files via upload
1 parent 7c88f4f commit af934ef

5 files changed

Lines changed: 35 additions & 53 deletions

File tree

CommandExecute.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ BEGIN
3636
--// Source: https://ola.hallengren.com //--
3737
--// License: https://ola.hallengren.com/license.html //--
3838
--// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
39-
--// Version: 2021-12-31 19:48:31 //--
39+
--// Version: 2022-01-02 13:58:13 //--
4040
----------------------------------------------------------------------------------------------------
4141

4242
SET NOCOUNT ON

DatabaseBackup.sql

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ BEGIN
8080
--// Source: https://ola.hallengren.com //--
8181
--// License: https://ola.hallengren.com/license.html //--
8282
--// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
83-
--// Version: 2021-12-31 19:48:31 //--
83+
--// Version: 2022-01-02 13:58:13 //--
8484
----------------------------------------------------------------------------------------------------
8585

8686
SET NOCOUNT ON
@@ -800,7 +800,7 @@ BEGIN
800800
IF (SELECT COUNT(*) FROM @Directories WHERE Mirror = 0) <> (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) AND (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) > 0
801801
BEGIN
802802
INSERT INTO @Errors ([Message], Severity, [State])
803-
SELECT 'The value for the parameter @Directory is not supported.', 16, 3
803+
SELECT 'The number of directories for the parameters @Directory and @MirrorDirectory has to be the same.', 16, 3
804804
END
805805

806806
IF (@Directory IS NOT NULL AND SERVERPROPERTY('EngineEdition') = 8) OR (@Directory IS NOT NULL AND @BackupSoftware = 'DATA_DOMAIN_BOOST')
@@ -818,7 +818,7 @@ BEGIN
818818
IF EXISTS (SELECT * FROM @Directories WHERE Mirror = 0 AND DirectoryPath = 'NUL') AND EXISTS(SELECT * FROM @Directories WHERE Mirror = 1)
819819
BEGIN
820820
INSERT INTO @Errors ([Message], Severity, [State])
821-
SELECT 'The value for the parameter @Directory is not supported.', 16, 6
821+
SELECT 'Mirrored backup is not supported when backing up to NUL', 16, 6
822822
END
823823

824824
----------------------------------------------------------------------------------------------------
@@ -835,12 +835,6 @@ BEGIN
835835
SELECT 'The value for the parameter @MirrorDirectory is not supported.', 16, 2
836836
END
837837

838-
IF (SELECT COUNT(*) FROM @Directories WHERE Mirror = 0) <> (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) AND (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) > 0
839-
BEGIN
840-
INSERT INTO @Errors ([Message], Severity, [State])
841-
SELECT 'The value for the parameter @MirrorDirectory is not supported.', 16, 3
842-
END
843-
844838
IF @BackupSoftware IN('SQLBACKUP','SQLSAFE') AND (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) > 1
845839
BEGIN
846840
INSERT INTO @Errors ([Message], Severity, [State])
@@ -859,12 +853,6 @@ BEGIN
859853
SELECT 'The value for the parameter @MirrorDirectory is not supported.', 16, 6
860854
END
861855

862-
IF EXISTS(SELECT * FROM @Directories WHERE Mirror = 0 AND DirectoryPath = 'NUL') AND EXISTS(SELECT * FROM @Directories WHERE Mirror = 1)
863-
BEGIN
864-
INSERT INTO @Errors ([Message], Severity, [State])
865-
SELECT 'The value for the parameter @MirrorDirectory is not supported.', 16, 7
866-
END
867-
868856
IF (@BackupSoftware IS NULL AND EXISTS(SELECT * FROM @Directories WHERE Mirror = 1) AND SERVERPROPERTY('EngineEdition') <> 3)
869857
BEGIN
870858
INSERT INTO @Errors ([Message], Severity, [State])
@@ -1176,7 +1164,7 @@ BEGIN
11761164
IF @Compress = 'Y' AND @BackupSoftware IS NULL AND NOT ((@Version >= 10 AND @Version < 10.5 AND SERVERPROPERTY('EngineEdition') = 3) OR (@Version >= 10.5 AND (SERVERPROPERTY('EngineEdition') IN (3, 8) OR SERVERPROPERTY('EditionID') IN (-1534726760, 284895786))))
11771165
BEGIN
11781166
INSERT INTO @Errors ([Message], Severity, [State])
1179-
SELECT 'The value for the parameter @Compress is not supported.', 16, 2
1167+
SELECT 'The value for the parameter @Compress is not supported. Backup compression is not supported in this version and edition of SQL Server.', 16, 2
11801168
END
11811169

11821170
IF @Compress = 'N' AND @BackupSoftware IN ('LITESPEED','SQLBACKUP','SQLSAFE') AND (@CompressionLevel IS NULL OR @CompressionLevel >= 1)
@@ -1276,7 +1264,7 @@ BEGIN
12761264
IF @BlockSize IS NOT NULL AND @URL IS NOT NULL AND @Credential IS NOT NULL
12771265
BEGIN
12781266
INSERT INTO @Errors ([Message], Severity, [State])
1279-
SELECT 'The value for the parameter @BlockSize is not supported.', 16, 4
1267+
SELECT 'BLOCKSIZE is not supported when backing up to URL with page blobs. See https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-backup-to-url', 16, 4
12801268
END
12811269

12821270
IF @BlockSize IS NOT NULL AND @BackupSoftware = 'DATA_DOMAIN_BOOST'
@@ -1328,7 +1316,7 @@ BEGIN
13281316
IF @MaxTransferSize IS NOT NULL AND @URL IS NOT NULL AND @Credential IS NOT NULL
13291317
BEGIN
13301318
INSERT INTO @Errors ([Message], Severity, [State])
1331-
SELECT 'The value for the parameter @MaxTransferSize is not supported.', 16, 4
1319+
SELECT 'MAXTRANSFERSIZE is not supported when backing up to URL with page blobs. See https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-backup-to-url', 16, 4
13321320
END
13331321

13341322
IF @MaxTransferSize IS NOT NULL AND @BackupSoftware = 'DATA_DOMAIN_BOOST'
@@ -1366,7 +1354,7 @@ BEGIN
13661354
IF @URL IS NOT NULL AND @Credential IS NOT NULL AND @NumberOfFiles <> 1
13671355
BEGIN
13681356
INSERT INTO @Errors ([Message], Severity, [State])
1369-
SELECT 'The value for the parameter @NumberOfFiles is not supported.', 16, 5
1357+
SELECT 'Backup striping to URL with page blobs is not supported. See https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-backup-to-url', 16, 5
13701358
END
13711359

13721360
IF @NumberOfFiles > 1 AND @BackupSoftware IN('SQLBACKUP','SQLSAFE') AND EXISTS(SELECT * FROM @Directories WHERE Mirror = 1)
@@ -2615,7 +2603,7 @@ BEGIN
26152603
WHEN @MaxTransferSize IS NULL AND @Compress = 'Y' AND @CurrentIsEncrypted = 1 AND @BackupSoftware IS NULL AND (@Version >= 13 AND @Version < 15.0404316) AND @Credential IS NULL THEN 65537
26162604
END
26172605

2618-
IF @CurrentDatabaseState = 'ONLINE'
2606+
IF @CurrentDatabaseState = 'ONLINE' AND NOT (@CurrentInStandby = 1)
26192607
BEGIN
26202608
IF EXISTS (SELECT * FROM sys.database_recovery_status WHERE database_id = DB_ID(@CurrentDatabaseName) AND database_guid IS NOT NULL)
26212609
BEGIN
@@ -2659,14 +2647,16 @@ BEGIN
26592647
AND [type] = 0
26602648
AND [file_id] = 1
26612649

2662-
IF @CurrentDatabaseState = 'ONLINE'
2650+
IF @CurrentDatabaseState = 'ONLINE' AND NOT (@CurrentInStandby = 1)
26632651
BEGIN
26642652
SELECT @CurrentLogLSN = last_log_backup_lsn
26652653
FROM sys.database_recovery_status
26662654
WHERE database_id = DB_ID(@CurrentDatabaseName)
26672655
END
26682656

2669-
IF @CurrentDatabaseState = 'ONLINE' AND EXISTS(SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_db_file_space_usage') AND name = 'modified_extent_page_count') AND (@CurrentAvailabilityGroupRole = 'PRIMARY' OR @CurrentAvailabilityGroupRole IS NULL)
2657+
IF @CurrentDatabaseState = 'ONLINE' AND NOT (@CurrentInStandby = 1)
2658+
AND EXISTS(SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_db_file_space_usage') AND name = 'modified_extent_page_count')
2659+
AND (@CurrentAvailabilityGroupRole = 'PRIMARY' OR @CurrentAvailabilityGroupRole IS NULL)
26702660
AND (@BackupType IN('DIFF','FULL') OR (@ChangeBackupType = 'Y' AND @CurrentBackupType = 'LOG' AND @CurrentRecoveryModel IN('FULL','BULK_LOGGED') AND @CurrentLogLSN IS NULL AND @CurrentDatabaseName <> 'master'))
26712661
AND (@ModificationLevel IS NOT NULL OR @MinBackupSizeForMultipleFiles IS NOT NULL OR @MaxFileSize IS NOT NULL)
26722662
BEGIN
@@ -2689,7 +2679,8 @@ BEGIN
26892679
END
26902680
END
26912681

2692-
IF @CurrentDatabaseState = 'ONLINE' AND EXISTS(SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_db_log_stats') AND name = 'log_since_last_log_backup_mb')
2682+
IF @CurrentDatabaseState = 'ONLINE' AND NOT (@CurrentInStandby = 1)
2683+
AND EXISTS(SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_db_log_stats') AND name = 'log_since_last_log_backup_mb')
26932684
BEGIN
26942685
SELECT @CurrentLastLogBackup = log_backup_time,
26952686
@CurrentLogSizeSinceLastLogBackup = log_since_last_log_backup_mb

DatabaseIntegrityCheck.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ BEGIN
3939
--// Source: https://ola.hallengren.com //--
4040
--// License: https://ola.hallengren.com/license.html //--
4141
--// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
42-
--// Version: 2021-12-31 19:48:31 //--
42+
--// Version: 2022-01-02 13:58:13 //--
4343
----------------------------------------------------------------------------------------------------
4444

4545
SET NOCOUNT ON

IndexOptimize.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ BEGIN
5353
--// Source: https://ola.hallengren.com //--
5454
--// License: https://ola.hallengren.com/license.html //--
5555
--// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
56-
--// Version: 2021-12-31 19:48:31 //--
56+
--// Version: 2022-01-02 13:58:13 //--
5757
----------------------------------------------------------------------------------------------------
5858

5959
SET NOCOUNT ON

MaintenanceSolution.sql

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ License: https://ola.hallengren.com/license.html
1010
1111
GitHub: https://github.com/olahallengren/sql-server-maintenance-solution
1212
13-
Version: 2021-12-31 19:48:31
13+
Version: 2022-01-02 13:58:13
1414
1515
You can contact me by e-mail at ola@hallengren.com.
1616
@@ -123,7 +123,7 @@ BEGIN
123123
--// Source: https://ola.hallengren.com //--
124124
--// License: https://ola.hallengren.com/license.html //--
125125
--// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
126-
--// Version: 2021-12-31 19:48:31 //--
126+
--// Version: 2022-01-02 13:58:13 //--
127127
----------------------------------------------------------------------------------------------------
128128

129129
SET NOCOUNT ON
@@ -459,7 +459,7 @@ BEGIN
459459
--// Source: https://ola.hallengren.com //--
460460
--// License: https://ola.hallengren.com/license.html //--
461461
--// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
462-
--// Version: 2021-12-31 19:48:31 //--
462+
--// Version: 2022-01-02 13:58:13 //--
463463
----------------------------------------------------------------------------------------------------
464464

465465
SET NOCOUNT ON
@@ -1179,7 +1179,7 @@ BEGIN
11791179
IF (SELECT COUNT(*) FROM @Directories WHERE Mirror = 0) <> (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) AND (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) > 0
11801180
BEGIN
11811181
INSERT INTO @Errors ([Message], Severity, [State])
1182-
SELECT 'The value for the parameter @Directory is not supported.', 16, 3
1182+
SELECT 'The number of directories for the parameters @Directory and @MirrorDirectory has to be the same.', 16, 3
11831183
END
11841184

11851185
IF (@Directory IS NOT NULL AND SERVERPROPERTY('EngineEdition') = 8) OR (@Directory IS NOT NULL AND @BackupSoftware = 'DATA_DOMAIN_BOOST')
@@ -1197,7 +1197,7 @@ BEGIN
11971197
IF EXISTS (SELECT * FROM @Directories WHERE Mirror = 0 AND DirectoryPath = 'NUL') AND EXISTS(SELECT * FROM @Directories WHERE Mirror = 1)
11981198
BEGIN
11991199
INSERT INTO @Errors ([Message], Severity, [State])
1200-
SELECT 'The value for the parameter @Directory is not supported.', 16, 6
1200+
SELECT 'Mirrored backup is not supported when backing up to NUL', 16, 6
12011201
END
12021202

12031203
----------------------------------------------------------------------------------------------------
@@ -1214,12 +1214,6 @@ BEGIN
12141214
SELECT 'The value for the parameter @MirrorDirectory is not supported.', 16, 2
12151215
END
12161216

1217-
IF (SELECT COUNT(*) FROM @Directories WHERE Mirror = 0) <> (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) AND (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) > 0
1218-
BEGIN
1219-
INSERT INTO @Errors ([Message], Severity, [State])
1220-
SELECT 'The value for the parameter @MirrorDirectory is not supported.', 16, 3
1221-
END
1222-
12231217
IF @BackupSoftware IN('SQLBACKUP','SQLSAFE') AND (SELECT COUNT(*) FROM @Directories WHERE Mirror = 1) > 1
12241218
BEGIN
12251219
INSERT INTO @Errors ([Message], Severity, [State])
@@ -1238,12 +1232,6 @@ BEGIN
12381232
SELECT 'The value for the parameter @MirrorDirectory is not supported.', 16, 6
12391233
END
12401234

1241-
IF EXISTS(SELECT * FROM @Directories WHERE Mirror = 0 AND DirectoryPath = 'NUL') AND EXISTS(SELECT * FROM @Directories WHERE Mirror = 1)
1242-
BEGIN
1243-
INSERT INTO @Errors ([Message], Severity, [State])
1244-
SELECT 'The value for the parameter @MirrorDirectory is not supported.', 16, 7
1245-
END
1246-
12471235
IF (@BackupSoftware IS NULL AND EXISTS(SELECT * FROM @Directories WHERE Mirror = 1) AND SERVERPROPERTY('EngineEdition') <> 3)
12481236
BEGIN
12491237
INSERT INTO @Errors ([Message], Severity, [State])
@@ -1555,7 +1543,7 @@ BEGIN
15551543
IF @Compress = 'Y' AND @BackupSoftware IS NULL AND NOT ((@Version >= 10 AND @Version < 10.5 AND SERVERPROPERTY('EngineEdition') = 3) OR (@Version >= 10.5 AND (SERVERPROPERTY('EngineEdition') IN (3, 8) OR SERVERPROPERTY('EditionID') IN (-1534726760, 284895786))))
15561544
BEGIN
15571545
INSERT INTO @Errors ([Message], Severity, [State])
1558-
SELECT 'The value for the parameter @Compress is not supported.', 16, 2
1546+
SELECT 'The value for the parameter @Compress is not supported. Backup compression is not supported in this version and edition of SQL Server.', 16, 2
15591547
END
15601548

15611549
IF @Compress = 'N' AND @BackupSoftware IN ('LITESPEED','SQLBACKUP','SQLSAFE') AND (@CompressionLevel IS NULL OR @CompressionLevel >= 1)
@@ -1655,7 +1643,7 @@ BEGIN
16551643
IF @BlockSize IS NOT NULL AND @URL IS NOT NULL AND @Credential IS NOT NULL
16561644
BEGIN
16571645
INSERT INTO @Errors ([Message], Severity, [State])
1658-
SELECT 'The value for the parameter @BlockSize is not supported.', 16, 4
1646+
SELECT 'BLOCKSIZE is not supported when backing up to URL with page blobs. See https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-backup-to-url', 16, 4
16591647
END
16601648

16611649
IF @BlockSize IS NOT NULL AND @BackupSoftware = 'DATA_DOMAIN_BOOST'
@@ -1707,7 +1695,7 @@ BEGIN
17071695
IF @MaxTransferSize IS NOT NULL AND @URL IS NOT NULL AND @Credential IS NOT NULL
17081696
BEGIN
17091697
INSERT INTO @Errors ([Message], Severity, [State])
1710-
SELECT 'The value for the parameter @MaxTransferSize is not supported.', 16, 4
1698+
SELECT 'MAXTRANSFERSIZE is not supported when backing up to URL with page blobs. See https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-backup-to-url', 16, 4
17111699
END
17121700

17131701
IF @MaxTransferSize IS NOT NULL AND @BackupSoftware = 'DATA_DOMAIN_BOOST'
@@ -1745,7 +1733,7 @@ BEGIN
17451733
IF @URL IS NOT NULL AND @Credential IS NOT NULL AND @NumberOfFiles <> 1
17461734
BEGIN
17471735
INSERT INTO @Errors ([Message], Severity, [State])
1748-
SELECT 'The value for the parameter @NumberOfFiles is not supported.', 16, 5
1736+
SELECT 'Backup striping to URL with page blobs is not supported. See https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-backup-to-url', 16, 5
17491737
END
17501738

17511739
IF @NumberOfFiles > 1 AND @BackupSoftware IN('SQLBACKUP','SQLSAFE') AND EXISTS(SELECT * FROM @Directories WHERE Mirror = 1)
@@ -2994,7 +2982,7 @@ BEGIN
29942982
WHEN @MaxTransferSize IS NULL AND @Compress = 'Y' AND @CurrentIsEncrypted = 1 AND @BackupSoftware IS NULL AND (@Version >= 13 AND @Version < 15.0404316) AND @Credential IS NULL THEN 65537
29952983
END
29962984

2997-
IF @CurrentDatabaseState = 'ONLINE'
2985+
IF @CurrentDatabaseState = 'ONLINE' AND NOT (@CurrentInStandby = 1)
29982986
BEGIN
29992987
IF EXISTS (SELECT * FROM sys.database_recovery_status WHERE database_id = DB_ID(@CurrentDatabaseName) AND database_guid IS NOT NULL)
30002988
BEGIN
@@ -3038,14 +3026,16 @@ BEGIN
30383026
AND [type] = 0
30393027
AND [file_id] = 1
30403028

3041-
IF @CurrentDatabaseState = 'ONLINE'
3029+
IF @CurrentDatabaseState = 'ONLINE' AND NOT (@CurrentInStandby = 1)
30423030
BEGIN
30433031
SELECT @CurrentLogLSN = last_log_backup_lsn
30443032
FROM sys.database_recovery_status
30453033
WHERE database_id = DB_ID(@CurrentDatabaseName)
30463034
END
30473035

3048-
IF @CurrentDatabaseState = 'ONLINE' AND EXISTS(SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_db_file_space_usage') AND name = 'modified_extent_page_count') AND (@CurrentAvailabilityGroupRole = 'PRIMARY' OR @CurrentAvailabilityGroupRole IS NULL)
3036+
IF @CurrentDatabaseState = 'ONLINE' AND NOT (@CurrentInStandby = 1)
3037+
AND EXISTS(SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_db_file_space_usage') AND name = 'modified_extent_page_count')
3038+
AND (@CurrentAvailabilityGroupRole = 'PRIMARY' OR @CurrentAvailabilityGroupRole IS NULL)
30493039
AND (@BackupType IN('DIFF','FULL') OR (@ChangeBackupType = 'Y' AND @CurrentBackupType = 'LOG' AND @CurrentRecoveryModel IN('FULL','BULK_LOGGED') AND @CurrentLogLSN IS NULL AND @CurrentDatabaseName <> 'master'))
30503040
AND (@ModificationLevel IS NOT NULL OR @MinBackupSizeForMultipleFiles IS NOT NULL OR @MaxFileSize IS NOT NULL)
30513041
BEGIN
@@ -3068,7 +3058,8 @@ BEGIN
30683058
END
30693059
END
30703060

3071-
IF @CurrentDatabaseState = 'ONLINE' AND EXISTS(SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_db_log_stats') AND name = 'log_since_last_log_backup_mb')
3061+
IF @CurrentDatabaseState = 'ONLINE' AND NOT (@CurrentInStandby = 1)
3062+
AND EXISTS(SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_db_log_stats') AND name = 'log_since_last_log_backup_mb')
30723063
BEGIN
30733064
SELECT @CurrentLastLogBackup = log_backup_time,
30743065
@CurrentLogSizeSinceLastLogBackup = log_since_last_log_backup_mb
@@ -4511,7 +4502,7 @@ BEGIN
45114502
--// Source: https://ola.hallengren.com //--
45124503
--// License: https://ola.hallengren.com/license.html //--
45134504
--// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
4514-
--// Version: 2021-12-31 19:48:31 //--
4505+
--// Version: 2022-01-02 13:58:13 //--
45154506
----------------------------------------------------------------------------------------------------
45164507

45174508
SET NOCOUNT ON
@@ -6413,7 +6404,7 @@ BEGIN
64136404
--// Source: https://ola.hallengren.com //--
64146405
--// License: https://ola.hallengren.com/license.html //--
64156406
--// GitHub: https://github.com/olahallengren/sql-server-maintenance-solution //--
6416-
--// Version: 2021-12-31 19:48:31 //--
6407+
--// Version: 2022-01-02 13:58:13 //--
64176408
----------------------------------------------------------------------------------------------------
64186409

64196410
SET NOCOUNT ON

0 commit comments

Comments
 (0)