From 63f9910332c60e1b11acd1d288dcc3beb39d6c3b Mon Sep 17 00:00:00 2001 From: Brent Ozar Date: Sat, 22 Nov 2025 06:48:57 -0800 Subject: [PATCH] Optimized locking check Turn it into dynamic SQL so that it works with earlier versions. --- Install-All-Scripts.sql | 13 ++++++++----- sp_Blitz.sql | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Install-All-Scripts.sql b/Install-All-Scripts.sql index 6f6f0b67..b8483698 100644 --- a/Install-All-Scripts.sql +++ b/Install-All-Scripts.sql @@ -4943,6 +4943,7 @@ IF EXISTS (SELECT * FROM sys.all_columns WHERE name = 'is_optimized_locking_on' BEGIN IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 272) WITH NOWAIT; + SET @StringToExecute = N' INSERT INTO [#BlitzResults] ( [CheckID] , [Priority] , @@ -4955,13 +4956,15 @@ IF EXISTS (SELECT * FROM sys.all_columns WHERE name = 'is_optimized_locking_on' SELECT 272 AS [CheckID] , 100 AS [Priority] , - 'Performance' AS [FindingsGroup] , - 'Optimized Locking Not Fully Set Up' AS [Finding] , + ''Performance'' AS [FindingsGroup] , + ''Optimized Locking Not Fully Set Up'' AS [Finding] , name, - 'https://www.brentozar.com/go/optimizedlocking' AS [URL] , - 'RCSI should be enabled on this database to get the full benefits of optimized locking.' AS [Details] + ''https://www.brentozar.com/go/optimizedlocking'' AS [URL] , + ''RCSI should be enabled on this database to get the full benefits of optimized locking.'' AS [Details] FROM sys.databases - WHERE is_optimized_locking_on = 1 AND is_read_committed_snapshot_on = 0; + WHERE is_optimized_locking_on = 1 AND is_read_committed_snapshot_on = 0;' + + EXEC(@StringToExecute); END; /* Check if target recovery interval <> 60 */ diff --git a/sp_Blitz.sql b/sp_Blitz.sql index 7874acf1..42b7a0a9 100644 --- a/sp_Blitz.sql +++ b/sp_Blitz.sql @@ -4943,6 +4943,7 @@ IF EXISTS (SELECT * FROM sys.all_columns WHERE name = 'is_optimized_locking_on' BEGIN IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 272) WITH NOWAIT; + SET @StringToExecute = N' INSERT INTO [#BlitzResults] ( [CheckID] , [Priority] , @@ -4955,13 +4956,15 @@ IF EXISTS (SELECT * FROM sys.all_columns WHERE name = 'is_optimized_locking_on' SELECT 272 AS [CheckID] , 100 AS [Priority] , - 'Performance' AS [FindingsGroup] , - 'Optimized Locking Not Fully Set Up' AS [Finding] , + ''Performance'' AS [FindingsGroup] , + ''Optimized Locking Not Fully Set Up'' AS [Finding] , name, - 'https://www.brentozar.com/go/optimizedlocking' AS [URL] , - 'RCSI should be enabled on this database to get the full benefits of optimized locking.' AS [Details] + ''https://www.brentozar.com/go/optimizedlocking'' AS [URL] , + ''RCSI should be enabled on this database to get the full benefits of optimized locking.'' AS [Details] FROM sys.databases - WHERE is_optimized_locking_on = 1 AND is_read_committed_snapshot_on = 0; + WHERE is_optimized_locking_on = 1 AND is_read_committed_snapshot_on = 0;' + + EXEC(@StringToExecute); END; /* Check if target recovery interval <> 60 */