web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

Constraint Error Using Professional Services Tool

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Community Member Profile Picture
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans