The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d. Dropping and re-creating the index may resolve this; otherwise, use another clustering key (2024)

Many of you may have encountered such a critical situation like some of the Table was working fine until just last minute without any Err and suddenly you may have faced an Err shown below so called Error 666


Msg 666, Level 16, State 2, Line 1
The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d.
Dropping and re-creating the index may resolve this; otherwise, use another clustering key.

What does mean ?

According to MSDN - "Clustered indexes sort and store the data rows in the table based on their key values. There can only be one clustered index per table, because the data rows themselves can only be sorted in one order. With few exceptions, every table should have a clustered index defined on the column, or columns, that offer the following"


  • Can be used for frequently used queries.
  • Provide a high degree of uniqueness
  • Can be used in range queries

If the clustered index is not created with the UNIQUE property forced to it!. So what ?

Here is the internal thing happens - "The Database Engine automatically adds a 4-byteUNIQUIFIERcolumn to the table. When it is required, the Database Engine automatically adds aUNIQUIFIERvalue to a row to make each key unique. The value starts with 0"

But, This column and it's values are used internally and cannot be seen or accessed by the users by accessing the table just like that.

You may ask now - Why do we need to worry about this situation ?

Let's have some scenario

USE [MyDatabase1]

GO


/*Table created with TWO column*/

CREATE TABLE MyTable1

(

Id INT, Names VARCHAR(20)

)

GO

/*Clustered Non-Unique key created on Id column*/

CREATE CLUSTERED INDEX CI_Id ON MyTable1(Id)

GO

/*2 Records inserted*/

INSERT MyTable1

SELECT 1,'SQL' UNION ALL

SELECT 2,'SERVER'

GO

/*Checking the Page allocations of the Table*/

SELECT%%Lockres%% [KeyHashValue], sys.fn_physlocformatter(%%Physloc%%) [File:Page:Slot], *FROMMyTable1

The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d. Dropping and re-creating the index may resolve this; otherwise, use another clustering key (1)

/*Checking the specific page (Page ID: 232)*/

DBCCTRACEON(3604)

DBCC PAGE('MyDatabase1',1,232,3)WITH TABLERESULTS

The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d. Dropping and re-creating the index may resolve this; otherwise, use another clustering key (2)

But, It has lot of other Information. Right. let's simplify the data and remove rest of them

/*Creating a Temp table to have the about result. So, That we can filter-it out as needed*/

CREATE TABLE #Info(ParentObject VARCHAR(50), [Object] VARCHAR(100), Field VARCHAR(50), Value VARCHAR(1000))

INSERT #Info

EXEC('DBCC PAGE(''MyDatabase1'',1,232,3) WITH TABLERESULTS')

/*We don't need Header and Buffer Info for now*/

DELETE #Info WHERE ParentObject in('BUFFER:','PAGE HEADER:')

SELECT * FROM #Info

The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d. Dropping and re-creating the index may resolve this; otherwise, use another clustering key (3)

As you can see above, There is one more Internal column has been added "UNIQUIFIER" to force the Internal Uniqueness for the Clustered Key.

And, Both the"UNIQUIFIER" record has a value as "0". Because, There is No duplicate on Clustered key column "Id". So, There is no need for Nth duplicate indication on"UNIQUIFIER" column. Right!

/*Insert 4 More records with 2 Duplicate Data on "Id" column*/

INSERT MyTable1

SELECT 3,'SQL SERVER'UNIONALL

SELECT 3,'UNIQUIFIER'UNIONALL

SELECT 3,'CLUSTERED'UNIONALL

SELECT 4,'NON-UNIQUE'

GO

TRUNCATE TABLE #Info

INSERT#Info

EXEC('DBCC PAGE(''MyDatabase1'',1,232,3) WITH TABLERESULTS')

DELETE#InfoWHEREParentObject in('BUFFER:','PAGE HEADER:')

SELECT*FROM#InfoWHERE Field IN ('UNIQUIFIER','Id','Names','KeyHashValue')

The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d. Dropping and re-creating the index may resolve this; otherwise, use another clustering key (4)

Can you guess ? What just happening ? Yes! - You are right!

We have inserted 4 New records and 3 of them duplicated (Id as "3"). Right ? So, The system wants to force the Unique value on "UNIQUIFIER" internal column. So, The "UNIQUIFIER" column have Nth duplicate indication!!

/*Deleted the records which Id column has "3"*/

DELETE MyTable1 WHERE Id = 3

GO

/*Inserted 3 records again*/

INSERT MyTable1

SELECT 3,'SQL SERVER'UNIONALL

SELECT 3,'UNIQUIFIER'UNIONALL

SELECT 3,'CLUSTERED'

GO

So, Can you guess - How many physical records will be there ?

Let's explore here

SELECT * FROM MyTable1

GO

The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d. Dropping and re-creating the index may resolve this; otherwise, use another clustering key (5)

Yeah! We have 6 Records as expected.

What would be the "UNIQUIFIER" internal value the system have ?

TRUNCATE TABLE#Info

INSERT#Info

EXEC('DBCC PAGE(''MyDatabase1'',1,232,3) WITH TABLERESULTS')

DELETE#InfoWHEREParentObject in('BUFFER:','PAGE HEADER:')

SELECT*FROM#InfoWHEREField IN ('UNIQUIFIER','Id','Names','KeyHashValue')

The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d. Dropping and re-creating the index may resolve this; otherwise, use another clustering key (6)

Yes! We just have 6 Records (Slot 0 to Slot 5) only. But, Did you see the "UNIQUIFIER" Internal column value ?

It has been Increased! Because, we already had 2 duplicate detected on "Id" column. Now, It has increased since than. It's not Reset anymore even when records deleted. That's the reason why the Internal column getting Increased even If the actual duplicate records removed/deleted!

So, I hope you would have guessed, What would happen If these kind of duplicate records DELETED and INSERTED multiple time with huge volume (Millions of transactions), The "UNIQUIFIER" internal column still increase along with the DELETED duplicated data and It's not RESET anymore as I said earlier.

Ok. Guess what ?

We will get such an Error, If we perform such a transaction as explained above without resetting the UNIQUIFIER, sometimes we can reach it's upper limit "2147483648"

The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d. Dropping and re-creating the index may resolve this; otherwise, use another clustering key (7)






















We will get such an Error If we INSERT 1 more duplicate record...

Msg 666, Level 16, State 2, Line 1
The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d.
Dropping and re-creating the index may resolve this; otherwise, use another clustering key.

The goal of this post is to give you an insight on how the UNIQUIFIER works and allow you to manually check for potential issue in your environment and avoiding such an error 666 and over come the situation

How to reset the value and unblock the situation ?

1.As per the Error suggests DROP and CREATE the Index
DROP INDEX MyTable1.CI_Id
GO
CREATE CLUSTERED INDEX CI_Id ON MyTable1(Id)
GO

Note: Rebuild Index will not help us

Check with the New page ID allocated and see whether the "UNIQUIFIER" value has been reset!

2. If still the Issue not been resolved

  • Create a new table with same structure (MyTable1_New)
  • Load the Data from an existing table (Using Import wizard Or Bulk Insert)
  • Create the Clustered Index
  • Archive/Remove the Old Table once make sure everything is resolved

Thanks for your time!

The maximum system-generated unique value for a duplicate group was exceeded for index with partition ID %I64d.  Dropping and re-creating the index may resolve this; otherwise, use another clustering key (2024)
Top Articles
Die fantastische Welt von Gumball Staffel 1 Episodenguide
Jared Jewelry and Diamonds – A Complete Review
Formulaire 3CEp - COPRAUDIT
San Fernando Craigslist Pets
Dsw Designer Shoe Warehouse Ann Arbor Photos
Autozone Locations Near Me
SSD an SATA Anschluss bei Futro S920
24 Hour Bookings Savannah
Food And Grocery Walmart Job
Calvert Er Wait Time
24/7 Walmarts Near Me
Wieting Funeral Home
Foodsmart Jonesboro Ar Weekly Ad
Ravens 24X7 Forum
9:00 A.m. Cdt
Partyline Ads for Wednesday, September 11, 2024
Celebrating Kat Dennings' Birthday: A Look Into The Life Of A Unique Talent
Nyu Paralegal Program
Craigslist Westchester Cars For Sale By Owner
Www.binghamton Craigslist.com
Cox Teacher Discount
Adams County 911 Live Incident
6 Best Doublelist Alternatives Worth Trying in 2024
Experience the Convenience of Po Box 790010 St Louis Mo
Wok Uberinternal
Hannaford Weekly Flyer Manchester Nh
Dreamhorse For Sale
Minecraft Light Level Texture Pack
Jen Chapin Gossip Bakery
Mercedes E-Klasse Rembekrachtigers voorraad | Onderdelenlijn.nl
What Jennifer Carpenter Has Been Doing Since Playing Debra Morgan On Dexter - Looper
Left Periprosthetic Femur Fracture Icd 10
South Park Old Fashioned Gif
Ts Central Nj
Crimson Draughts.
Keanu Reeves cements his place in action genre with ‘John Wick: Chapter 4’
Alison Pest Control
World History Kazwire
Uc Davis Tech Management Minor
Dom Tradingview
What Is TAA Trade Agreements Act Compliance Trade Agreement Act Certification
Beauty TikTok Star Mireya Rios' Magical Wedding on the Beaches of Mexico
Limestone Bank Hillview
Hooda Math—Games, Features, and Benefits — Mashup Math
Nailery Open Near Me
How To Buy Taylor Swift Tickets By Navigating Ticketek's Stress-Inducing System
Neo Geo Bios Raspberry Pi 3
Empire Of Light Showtimes Near Santikos Entertainment Palladium
Mugshots In Waco Texas
City Of Omaha Efinance
La tarifa "Go Hilton" para los amigos y familiares de los miembros del equipo - Lo que debe saber
Used Go Karts For Sale Near Me Craigslist
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5842

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.