Skip to content

Violation of PRIMARY KEY constraint 'PK_indexDefragStatus_v40' #6

Open
@FinickyCode

Description

@FinickyCode

I am seeing the exception:

Looping through our list of databases and checking for fragmentation...
...
working on DBNAME...
Violation of PRIMARY KEY constraint 'PK_indexDefragStatus_v40'. Cannot insert duplicate key in object 'dbo.dba_indexDefragStatus'. The duplicate key value is (9, 50099219, 1, 1). (Line Number: 442)

When executing the SELECT portion of the script on Line 442, I get two rows:

databaseID	databaseName	objectID	indexID	partitionNumber	fragmentation	page_count	range_scan_count	scanDate
9	  	[DBNAME]	50099219	1	1	61.1909650924025	1948	0	2018-07-26 12:19:31.040
9	  	[DBNAME]	50099219	1	1	61.1909650924025	1948	84	2018-07-26 12:19:31.040

These two rows have the same values for all the primary keys in the table (databaseID, indexID, objectID, partitionNumber).

Is this a bug in the script, or is there something wrong the data in the instance I'm running the script on?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions