Skip to content

Commit 9381edd

Browse files
BrentOzarclaude
andcommitted
#3888 Fix 4 compatibility issues from Copilot review
- sp_BlitzWho: Add SQL Server 2016 SP2+ minimum build check (build 5026) - sp_BlitzCache: Check compat level 130+ up front for STRING_SPLIT support - sp_kill: Remove USE statement for Azure SQL DB compatibility, use 3-part naming - sp_BlitzIndex: Update help text to say "2014 and older" instead of "2005 and 2000" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 22b3d4f commit 9381edd

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

sp_BlitzCache.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,13 @@ BEGIN
828828
RETURN;
829829
END;
830830

831+
/* Check database compatibility level for STRING_SPLIT support */
832+
IF (SELECT compatibility_level FROM sys.databases WHERE database_id = DB_ID()) < 130
833+
BEGIN
834+
RAISERROR('sp_BlitzCache requires database compatibility level 130 or higher. If your user databases aren''t at that compat level yet, install sp_BlitzCache in master instead.', 16, 1);
835+
RETURN;
836+
END;
837+
831838
IF(@OutputType = 'NONE' AND (@OutputTableName IS NULL OR @OutputSchemaName IS NULL OR @OutputDatabaseName IS NULL))
832839
BEGIN
833840
RAISERROR('This procedure should be called with a value for all @Output* parameters, as @OutputType is set to NONE',12,1);

sp_BlitzIndex.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ versions for free, watch training videos on how it works, get more info on
9898
the findings, contribute your own code, and more.
9999
100100
Known limitations of this version:
101-
- Only Microsoft-supported versions of SQL Server. Sorry, 2005 and 2000.
101+
- Only Microsoft-supported versions of SQL Server. Sorry, 2014 and older.
102102
- Index create statements are just to give you a rough idea of the syntax. It includes filters and fillfactor.
103103
-- Example 1: index creates use ONLINE=? instead of ONLINE=ON / ONLINE=OFF. This is because it is important
104104
for the user to understand if it is going to be offline and not just run a script.

sp_BlitzWho.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ SELECT
1717
WHEN CONVERT(NVARCHAR(128), SERVERPROPERTY ('PRODUCTVERSION')) LIKE '10%' THEN 0
1818
WHEN CONVERT(NVARCHAR(128), SERVERPROPERTY ('PRODUCTVERSION')) LIKE '11%' THEN 0
1919
WHEN CONVERT(NVARCHAR(128), SERVERPROPERTY ('PRODUCTVERSION')) LIKE '12%' THEN 0
20+
WHEN CONVERT(NVARCHAR(128), SERVERPROPERTY ('PRODUCTVERSION')) LIKE '13%'
21+
AND CAST(PARSENAME(CONVERT(NVARCHAR(128), SERVERPROPERTY ('PRODUCTVERSION')), 2) AS INT) < 5026 THEN 0
2022
ELSE 1
2123
END
2224
) = 0
2325
BEGIN
2426
DECLARE @msg VARCHAR(8000);
25-
SELECT @msg = 'Sorry, sp_BlitzWho doesn''t work on versions of SQL prior to 2016.' + REPLICATE(CHAR(13), 7933);
27+
SELECT @msg = 'Sorry, sp_BlitzWho doesn''t work on versions of SQL prior to 2016 SP2.' + REPLICATE(CHAR(13), 7933);
2628
PRINT @msg;
2729
RETURN;
2830
END;

sp_kill.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,10 @@ For more info, visit http://FirstResponderKit.org
651651
SET @ObjectFullName = @OutputDatabaseName + N'.' + @OutputSchemaName + N'.' + @OutputTableName;
652652

653653
/* Create table if it doesn't exist */
654-
SET @StringToExecute = N'USE ' + @OutputDatabaseName + N';
654+
SET @StringToExecute = N'
655655
IF EXISTS(SELECT * FROM ' + @OutputDatabaseName + N'.INFORMATION_SCHEMA.SCHEMATA WHERE QUOTENAME(SCHEMA_NAME) = ''' + @OutputSchemaName + N''')
656656
AND NOT EXISTS (SELECT * FROM ' + @OutputDatabaseName + N'.INFORMATION_SCHEMA.TABLES WHERE QUOTENAME(TABLE_SCHEMA) = ''' + @OutputSchemaName + N''' AND QUOTENAME(TABLE_NAME) = ''' + @OutputTableName + N''')
657-
CREATE TABLE ' + @OutputSchemaName + N'.' + @OutputTableName + N' (
657+
CREATE TABLE ' + @ObjectFullName + N' (
658658
Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,
659659
ServerName NVARCHAR(128) NULL,
660660
CheckDate DATETIMEOFFSET NULL,

0 commit comments

Comments
 (0)