When you try to post Analytical Accounting transactions in Microsoft Dynamics GP, you may receive the following error message:
[Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY contraint 'PKAAG30000', cannot insert duplicate key in object 'AAG30003'
Note In this error message, AAG30000 is a placeholder for the table. The word "contraint" is a misspelling of "constraint."
The actual error message that you receive may contain one of the following tables:
This problem occurs because the next available value (aaRowID) indicated for this table (aaTableID) in the AAG00102 table has already been used in the applicable table (or series of sub-tables).
For example, the '30000' table in the AAG00102 table will look at the AAG30000, AAG30001, AAG30002 and AAG30003 tables, so be careful to check all the tables in the series for the applicable table.
To work around this problem, use one of the following methods below to compare the highest used value in the AA table (and sub-tables) against the next available value stored in the AAG00102 table.
Note Before you follow the instructions in this article, make sure that you have a complete backup copy of the database that you can restore if a problem occurs.
Method 1 - Use SQL Script to update values in AAG00102 for most AA tables
You can download a SQL script using the link below and run it in SQL Server Management Studio against the company database to automatically update the next available number stored in the AAG00102 table as compared to the last used value in the AA table. The script will look at the following tables: AAG10000, AAG20000, AAG30000, AAG00201, AAG00400, AAG00401, AAG00500, AAG00600, AAG00900 and AAG00903. So it looks at most of the AA tables, but not all, and not sub-tables for a series. To obtain the script, visit the following Microsoft Web site: