Violation of primary key



Violation of PRIMARY KEY constraint 'PK_CUSTOM2'. Cannot insert
duplicate key in object 'MHGROUP.Custom2'

Is there ANY other reason this violation of the primary key would
happen OTHER than a trying to insert a duplicate record?

This sql statement false due to the primary key violation:

Insert Into MHGROUP.Custom2
Select
ClientNumber,
MatterNumber,
MatterDescription,
'Y'
From MG_EliteMatters EM
Left Outer Join MHGROUP.Custom2 C2
On C2.CPARENT_ALIAS = EM.ClientNumber
And C2.Custom_ALIAS = EM.MatterNumber
Where CPARENT_ALIAS Is Null And Custom_ALIAS Is Null

---Custom2
CREATE TABLE [MHGROUP].[CUSTOM2](
[CPARENT_ALIAS] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_AS
NOT NULL,
[CUSTOM_ALIAS] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL,
[C_DESCRIPT] [varchar](254) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL,
[ENABLED] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_CUSTOM2] PRIMARY KEY CLUSTERED
(
[CPARENT_ALIAS] ASC,
[CUSTOM_ALIAS] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

--MG_EliteMatters
CREATE TABLE [dbo].[MG_EliteMatters](
[Matters] [varchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ClientNumber] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL,
[ClientDescription] [varchar](254) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL,
[MatterNumber] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL,
[MatterDescription] [varchar](254) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL,
[LastDateModified] [datetime] NULL,
[PracticeArea] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL
) ON [PRIMARY]
.



Relevant Pages

  • Re: violation of unique constraint in distribution database
    ... What is the exact error message you are getting? ... "Violation of PRIMARY KEY ... duplicate key in object '#2E0AB83D'." ... we are getting violation of unique constraint in distribution database. ...
    (microsoft.public.sqlserver.replication)
  • Re: normalization review
    ... Having one phone have a number of lines has no impact on the normalization ... violation. ... The location column does not depend on the ENTIRE primary key! ...
    (comp.databases.theory)
  • PK violation error during replication
    ... Violation of PRIMARY KEY ... constraint 'PK__@snapshot_seqnos__66DE2538'. ... duplicate key in object '#65EA00FF'. ...
    (microsoft.public.sqlserver.server)
  • Re: Opinions on approach, please...
    ... which allow for nulls in the middle of a primary key? ... justify their own particular violation of standards. ... Mr Wagner, it was the only key shown and the reasons you've given are, by ...
    (comp.lang.cobol)
  • Handle SQL Adapter Exception
    ... The adapter "SQL" raised an error message. ... PRIMARY KEY constraint 'PK_Student'. ... duplicate key in object 'Student'." ...
    (microsoft.public.biztalk.general)