Skip to content

sp_BlitzIndex assumes that Primary Key is clustered and does not explicitly script it as such #3770

@rancourt-martin

Description

@rancourt-martin

Version of the script
SELECT @Version = '8.28', @VersionDate = '20251124';

What is the current behavior?

sp_BlitzIndex seems to assume that Primary Key is clustered for the "create tsql" and does not explicitly script it out when running the sp

If the current behavior is a bug, please provide the steps to reproduce.

run sp_blitzIndex @DatabaseName, @SchemaName, @TableName on a table that has a NONCLUSTERED Primary Key

What is the expected behavior?

ALTER TABLE [mydb].[dbo].[my_not_so_best_practice_table] ADD CONSTRAINT [xyz_constraint] PRIMARY KEY NONCLUSTERED

Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures?

Microsoft SQL Server 2022 (RTM-CU21) (KB5065865) - 16.0.4215.2 (X64) Aug 11 2025 13:24:21 Copyright (C) 2022 Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2019 Datacenter 10.0 (Build 17763: ) (Hypervisor)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions