#3888 Fix 4 compatibility issues from Copilot review#3889
Conversation
- 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>
There was a problem hiding this comment.
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_BlitzCacheto ensureSTRING_SPLITsupport with a clearer error message. - Updates
sp_killpersistent output-table creation to avoidUSEby switching to database-qualified naming. - Refreshes
sp_BlitzIndexhelp 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
| 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' ( |
There was a problem hiding this comment.
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.
| 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); |
There was a problem hiding this comment.
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).
- 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>
There was a problem hiding this comment.
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.
| IF @AzureSQLDB = 1 | ||
| SET @ObjectFullName = @OutputSchemaName + N'.' + @OutputTableName; | ||
| ELSE | ||
| SET @ObjectFullName = @OutputDatabaseName + N'.' + @OutputSchemaName + N'.' + @OutputTableName; |
There was a problem hiding this comment.
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.
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>
Summary
Fixes 4 compatibility issues identified by GitHub Copilot's review of PR #3885:
sys.dm_exec_query_statscolumns (last_dop,min_dop,max_dop,last_grant_kb) not available before SP2STRING_SPLITrequires it. Directs users to install inmasterif their database compat level is too lowUSEstatement in persistent output table section (not supported on Azure SQL DB), replace with 3-part naming via@ObjectFullNamewhich works on both Azure and on-premCloses #3888
Test plan
PARSENAMElogic correctly parses SP2 build number (5026) vs SP1 (4001)EXEC dbo.sp_BlitzWhoruns successfullyEXEC dbo.sp_BlitzCache @Top = 1runs successfully (compat level 170 passes the check)EXEC dbo.sp_killruns successfullyEXEC dbo.sp_BlitzIndex @Help = 1shows updated "Sorry, 2014 and older" text🤖 Generated with Claude Code