Skip to content

#3888 Fix 4 compatibility issues from Copilot review#3889

Merged
BrentOzar merged 3 commits intodevfrom
3888_copilot_compat_fixes
Apr 7, 2026
Merged

#3888 Fix 4 compatibility issues from Copilot review#3889
BrentOzar merged 3 commits intodevfrom
3888_copilot_compat_fixes

Conversation

@BrentOzar
Copy link
Copy Markdown
Member

Summary

Fixes 4 compatibility issues identified by GitHub Copilot's review of PR #3885:

  • sp_BlitzWho: Add SQL Server 2016 SP2+ minimum build check (build >= 5026) to the version gate, since ExpertMode references sys.dm_exec_query_stats columns (last_dop, min_dop, max_dop, last_grant_kb) not available before SP2
  • sp_BlitzCache: Add database compatibility level 130+ check up front with a clear error message, since STRING_SPLIT requires it. Directs users to install in master if their database compat level is too low
  • sp_kill: Remove USE statement in persistent output table section (not supported on Azure SQL DB), replace with 3-part naming via @ObjectFullName which works on both Azure and on-prem
  • sp_BlitzIndex: Update help text from "Sorry, 2005 and 2000" to "Sorry, 2014 and older" to match the 2016+ minimum

Closes #3888

Test plan

  • Installed all 4 updated procs on local SQL Server 2025
  • Verified PARSENAME logic correctly parses SP2 build number (5026) vs SP1 (4001)
  • EXEC dbo.sp_BlitzWho runs successfully
  • EXEC dbo.sp_BlitzCache @Top = 1 runs successfully (compat level 170 passes the check)
  • EXEC dbo.sp_kill runs successfully
  • EXEC dbo.sp_BlitzIndex @Help = 1 shows updated "Sorry, 2014 and older" text

🤖 Generated with Claude Code

- 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>
Copilot AI review requested due to automatic review settings April 7, 2026 10:58
@BrentOzar BrentOzar added this to the 2026-04 Release milestone Apr 7, 2026
@BrentOzar BrentOzar self-assigned this Apr 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses four SQL Server/Azure compatibility gaps in the First Responder Kit stored procedures identified during review of PR #3885.

Changes:

  • Tightens sp_BlitzWho’s version gate to require SQL Server 2016 SP2+ for ExpertMode DMV columns.
  • Adds an early compatibility level (130+) check to sp_BlitzCache to ensure STRING_SPLIT support with a clearer error message.
  • Updates sp_kill persistent output-table creation to avoid USE by switching to database-qualified naming.
  • Refreshes sp_BlitzIndex help text to reflect the current minimum supported SQL Server versions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
sp_kill.sql Replaces USE-based dynamic SQL with database-qualified object naming for persistent output table creation.
sp_BlitzWho.sql Adds SQL Server 2016 SP2 (build 5026) minimum build gating and updates the “too old” message.
sp_BlitzCache.sql Adds an upfront DB compatibility level check (>= 130) before using STRING_SPLIT.
sp_BlitzIndex.sql Updates help/limitations text to remove outdated version references.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sp_kill.sql Outdated
Comment on lines +654 to +657
SET @StringToExecute = N'
IF EXISTS(SELECT * FROM ' + @OutputDatabaseName + N'.INFORMATION_SCHEMA.SCHEMATA WHERE QUOTENAME(SCHEMA_NAME) = ''' + @OutputSchemaName + N''')
AND NOT EXISTS (SELECT * FROM ' + @OutputDatabaseName + N'.INFORMATION_SCHEMA.TABLES WHERE QUOTENAME(TABLE_SCHEMA) = ''' + @OutputSchemaName + N''' AND QUOTENAME(TABLE_NAME) = ''' + @OutputTableName + N''')
CREATE TABLE ' + @OutputSchemaName + N'.' + @OutputTableName + N' (
CREATE TABLE ' + @ObjectFullName + N' (
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Azure SQL Database (EngineEdition=5), database-qualified object names (e.g. [db].[schema].[table] and [db].INFORMATION_SCHEMA.*) are not supported and will raise an error. With this change, the dynamic SQL now uses @OutputDatabaseName prefixes and CREATE TABLE @ObjectFullName (3-part), which likely breaks the persistent output table path on Azure.

Consider branching on @AzureSQLDB: when running on Azure SQL DB (or when @OutputDatabaseName = QUOTENAME(DB_NAME())), omit the database qualifier and use 2-part names (schema.table) and unqualified INFORMATION_SCHEMA views, while keeping 3-part naming for on-prem/MI where it’s supported.

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +27
WHEN CONVERT(NVARCHAR(128), SERVERPROPERTY ('PRODUCTVERSION')) LIKE '13%'
AND CAST(PARSENAME(CONVERT(NVARCHAR(128), SERVERPROPERTY ('PRODUCTVERSION')), 2) AS INT) < 5026 THEN 0
ELSE 1
END
) = 0
BEGIN
DECLARE @msg VARCHAR(8000);
SELECT @msg = 'Sorry, sp_BlitzWho doesn''t work on versions of SQL prior to 2016.' + REPLICATE(CHAR(13), 7933);
SELECT @msg = 'Sorry, sp_BlitzWho doesn''t work on versions of SQL prior to 2016 SP2.' + REPLICATE(CHAR(13), 7933);
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version gate now requires SQL Server 2016 SP2+ (build >= 5026), but the @Help output still states “Only SQL Server 2016 and newer.” This is inconsistent and may confuse users who are on 2016 RTM/SP1.

Update the help text to explicitly say 2016 SP2+ (or clarify that 2016 RTM/SP1 aren’t supported when @ExpertMode is used).

Copilot uses AI. Check for mistakes.
- sp_kill: Branch on @AzureSQLDB for output table creation — use 2-part
  names on Azure SQL DB, 3-part names on on-prem/MI
- sp_BlitzWho: Update help text to say "2016 SP2 and newer" to match
  the version gate

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +651 to +654
IF @AzureSQLDB = 1
SET @ObjectFullName = @OutputSchemaName + N'.' + @OutputTableName;
ELSE
SET @ObjectFullName = @OutputDatabaseName + N'.' + @OutputSchemaName + N'.' + @OutputTableName;
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Azure SQL DB, Section 10 now builds @ObjectFullName as a 2-part name (schema.table) to avoid unsupported 3-part naming. However, later in the proc (during the kill loop persistent-table update) @ObjectFullName is rebuilt as a 3-part name unconditionally, which will still fail on Azure when @ExecuteKills='Y' and output logging is enabled. Consider applying the same @AzureSQLDB branching for the later UPDATE/INSERT statements (or avoid overwriting @ObjectFullName) so the persistent table logic is consistently Azure-safe.

Copilot uses AI. Check for mistakes.
The post-kill UPDATE at line 853 was unconditionally rebuilding
@ObjectFullName as a 3-part name, which would fail on Azure SQL DB.
Apply the same @AzureSQLDB branching used in Section 10.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@BrentOzar BrentOzar merged commit c20b37f into dev Apr 7, 2026
@BrentOzar BrentOzar deleted the 3888_copilot_compat_fixes branch April 7, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix 4 compatibility issues from Copilot review of PR #3885

2 participants