• I can imagine some reasonable uses for an IDENTITY column where duplicates are allowed / expected.

    Say we have some sort of versioning system where the version number comprises a major number and a minor number. The business rules state that the minor version number is reset whenever the major version number changes. The decision to change major version numbers is triggered by an explicit user action and is infrequent, but the minor number should increment automatically whenever any change is logged (by inserting a new table row) which is expected to be a frequent occurrence. The minor number could be modelled reasonably by an IDENTITY column that is reset to 0 whenever the major number is incremented. The table that implements this versioning system could have a structure something like the following:

    CREATE TABLE dbo.Version (

    MajorNumber int NOT NULL,

    MinorNumber int NOT NULL IDENTITY(0, 1),

    DateStamp datetime NOT NULL DEFAULT(GETDATE()),

    Comment nvarchar(1000) NULL,

    CONSTRAINT PK_Version PRIMARY KEY CLUSTERED (MajorNumber, MinorNumber),

    CONSTRAINT CK_VersionNumber CHECK (MajorNumber >= 1 AND MinorNumber >= 0)

    )