title: SQL INSERT statement conflicted with the CHECK constraint
body: <p>I am getting this error </p>
  
  <ul>
  <li>InsertRecord(InsertRow): HResult of -2147217873 (80040e2f) </li>
  <li>Error Source: Microsoft OLE DB Provider for SQL Server Error </li>
  <li>Description :  The INSERT statement conflicted with the CHECK constraint <code>CK_ContactName</code>. The conflict occurred in database EPIC.7.5_GR_SM_ETLTRAINING; table dbo.ContactName.</li>
  </ul>
  
  <p>The Statements</p>
  
  <pre><code>CREATE TABLE [dbo].[ContactName](
  [UniqContactName] [dbo].[DM_UNIQID] IDENTITY(65536,1) NOT NULL,
  [UniqFixedContactName] [dbo].[DM_UNIQID] NOT NULL,
  [UniqEntity] [dbo].[DM_UNIQID] NOT NULL,
  [LkPrefix] [dbo].[DM_PREFIX] NOT NULL,
  [FullName] [dbo].[DM_NAME] NOT NULL,
  [FirstName] [varchar](30) NOT NULL,
  [MiddleName] [varchar](16) NOT NULL,
  [LastName] [varchar](30) NOT NULL,
  [LkSuffix] [dbo].[DM_SUFFIX] NOT NULL,
  [DescriptionOf] [dbo].[DM_DESC_050] NOT NULL,
  [Title] [dbo].[DM_TITLE] NOT NULL,
  [Department] [dbo].[DM_DEPARTMENT] NOT NULL,
  [UniqContactAddressMain] [dbo].[DM_UNIQID] NOT NULL,
  [UniqContactAddressEmployer] [dbo].[DM_UNIQID] NOT NULL,
  [UniqContactNumberMain] [dbo].[DM_UNIQID] NOT NULL,
  [UniqContactNumberEmailMain] [dbo].[DM_UNIQID] NOT NULL,
  [ContactMethodCode] [char](1) NOT NULL,
  [InformalHeading] [varchar](50) NOT NULL,
  [FormalHeading] [varchar](50) NOT NULL,
  [BirthDate] [dbo].[DM_DATE] NULL,
  [GenderCode] [char](1) NOT NULL,
  [SSN] [char](9) NOT NULL,
  [MaritalStatusCode] [char](1) NOT NULL,
  [RelationToInsuredCode] [char](2) NOT NULL,
  [LkLanguage] [dbo].[DM_LANGUAGE] NOT NULL,
  [Comments] [dbo].[DM_COMMENT] NOT NULL,
  [BillingDeliveryCode] [char](1) NOT NULL,
  [ServicingDeliveryCode] [char](1) NOT NULL,
  [MarketingDeliveryCode] [char](1) NOT NULL,
  [CategoryCode] [char](1) NOT NULL,
  [EmployerName] [dbo].[DM_NAME] NOT NULL,
  [LkOccupation] [dbo].[DM_OCCUPATION] NOT NULL,
  [HiredDate] [dbo].[DM_DATE] NULL,
  [YearsEmployed] [smallint] NULL,
  [YearsPriorEmployer] [smallint] NULL,
  [FEIN] [char](9) NOT NULL,
  [DUNSNumber] [char](9) NOT NULL,
  [CdNAICSCode] [char](6) NOT NULL,
  [CdSICCode] [char](8) NOT NULL,
  [BusinessTypeCode] [char](2) NOT NULL,
  [BusinessTypeOtherDesc] [varchar](50) NOT NULL,
  [NumberEmployees] [smallint] NULL,
  [NumberMembersManagers] [int] NULL,
  [BusinessStartedDate] [datetime] NULL,
  [NatureOfBusinessCode] [char](2) NOT NULL,
  [NatureOfBusinessOtherDesc] [varchar](50) NOT NULL,
  [CreditBureauNameCode] [char](5) NOT NULL,
  [CreditBureauNameOtherDesc] [varchar](50) NOT NULL,
  [CreditBureauIDNumber] [varchar](30) NOT NULL,
  [DriverLicenseNumber] [varchar](25) NOT NULL,
  [LicensedState] [char](4) NOT NULL,
  [LicensedDate] [datetime] NULL,
  [LicensedMADate] [dbo].[DM_DATE] NULL,
  [DriverTypeCode] [char](1) NOT NULL,
  [GoodStudentCode] [char](1) NOT NULL,
  [DriverTrainingCode] [char](1) NOT NULL,
  [AccidentPreventionCourseDate] [dbo].[DM_DATE] NULL,
  [CommercialExperienceBeganDate] [dbo].[DM_DATE] NULL,
  [MatchClientNameOf] [smallint] NOT NULL,
  [InsertedByCode] [dbo].[DM_INSERTUPDATEBYCODE] NOT NULL,
  [InsertedDate] [dbo].[DM_DATETIME] NOT NULL,
  [UpdatedByCode] [dbo].[DM_INSERTUPDATEBYCODE] NOT NULL,
  [UpdatedDate] [dbo].[DM_DATETIME] NULL,
  [Flags] [dbo].[DM_FLAGS] NOT NULL,
  [ts] [datetime] NOT NULL,
  [SIN] [char](9) NOT NULL,
  [BusinessNumber] [varchar](30) NOT NULL,
  [BusinessIDNumber] [varchar](30) NOT NULL,
  [IBCCode] [char](6) NOT NULL,
       CONSTRAINT [PK_ContactName] PRIMARY KEY NONCLUSTERED ALTER TABLE [dbo].[ContactName]  
     WITH CHECK ADD  CONSTRAINT [CK_ContactName] 
     CHECK  ((
            [UniqContactName]=(-1) 
            AND [UniqEntity]=(-1) 
            OR  [UniqContactName]&gt;(-1) 
            AND [UniqEntity]&gt;(-1)
            ))
     GO
  </code></pre>
  
  <p>I have checked contactName db and all the rows from uniqueContactName all have a value above 65000, then for UniqEntity they all are above 65000 as well.</p>
  
  <p>Does anyone have an idea why this would fail? </p>