Skip to main content

Notifications

Microsoft Dynamics SL (Archived)

Constraint Error Using Professional Services Tool

Posted on by 160

Hi

I am using the Professional Services Tool to consolidate vendor ID’s in SL7. When I do so I often get the below constraint violation for vendor id’s on the APHist and Inactive_vendor tables. I’m not sure if deleting the entries on either of these tables for the id’s in question is a good idea for enabling the consolidation of the vendor records. Has anyone run into this before?

 ERROR: Violation of Primary Key constraint ‘PK-Inactive_Vendor’ Cannot insert duplicate key in object ‘dbo.Inactive_Vendor’.

The duplicate key value is (xxxxxxxxxx). The statement is terminated.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Constraint Error Using Professional Services Tool

    Hi Doug,

    I did  sp_help on the APHIST table and did find the primary keys that are on that table.

    So if you know the vendor that you are getting this error you we can check the aphist table for the 3 fields to see if there are any duplicates.

    APHist0 clustered, unique, primary key located on PRIMARY VendId, CpnyID, FiscYr

    Please look at the aphist table to see if there are any duplicates for the vendor that is getting the error when you are combining the information.

    select * from aphist where vendid = 'XXXXXX'

    --replace XXXXXX with the vendors ID,

    Make sure to look at the vendid, cpnyid, and fiscyr fields to see if there may be any data that is not correct.

    A unique key violation can occur if you try to insert a record that already exists, but it can also occur if you try to insert a record with a blank key value. As an example, on APHist, the unique key is company ID, vendor ID, and fiscal year. If you tried to insert a record for vendor SMITH, company A, fiscal year 2007 and there was already a record with those key values, you would get a unique key violation. If you tried to insert a record for vendor SMITH, fiscal year 2007, and no company ID, you would also get an error.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans