Error message when you try to perform the year-end closing routine in General Ledger in Microsoft Dynamics GP: "Violation of PRIMARY KEY constraint 'PK##0671112'"


Source: Microsoft Support

RAPID PUBLISHING

RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION THAT IS CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED TO SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

Symptoms


When you try to perform the year-end closing routine in General Ledger in Microsoft Dynamics GP, you receive the following error message:

[Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY constraint 'PK##0671112'. Cannot insert duplicate key in object '##0671112'

Cause


The year-end closing transactions contain a currency that is not assigned to an account.

Resolution


To resolve this problem, assign the currency to the appropriate account. To do this, follow these steps:
  1. Have all users exit Microsoft Dynamics GP.
  2. Restore a backup of the company database that was made before you tried to perform the General Ledger year-end closing routine.
  3. Start the Support Administrator Console, Microsoft SQL Query Analyzer, or SQL Server Management Studio. To do this, use one of the following methods depending on the program that you are using.

    Method 1: For SQL Server Desktop Engine

    If you are using SQL Server Desktop Engine (also known as MSDE 2000), start the Support Administrator Console. To do this, click Start, point to All Programs, point to Microsoft Administrator Console, and then click Support Administrator Console.

    Method 2: For SQL Server 2000

    If you are using SQL Server 2000, start SQL Query Analyzer. To do this, click Start, point to All Programs, point to Microsoft SQL Server, and then click Query Analyzer.

    Method 3: For SQL Server 2005

    If you are using SQL Server 2005, start SQL Server Management Studio. To do this, click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Management Studio.
  4. Run the following script against the company database:
    Select CURNCYID FROM GL20000

  5. Make note of all currencies displayed in the CURNCYID column.
  6. Start Microsoft Dynamics GP, and then log in as user ‘sa’.
  7. On the Cards menu, point to Financial, and then click Account.
  8. In the Account field, type the retained earnings account number.
  9. Click Currency.
  10. In the Select Account Currencies window, click to select the Currency ID check boxes that you noted in step 5.
  11. Perform the year-end closing routine in General Ledger.

DISCLAIMER

MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, THE RELIABILITY OR THE ACCURACY OF THE INFORMATION THAT IS CONTAINED IN THE DOCUMENTS AND THE RELATED GRAPHICS PUBLISHED ON THIS WEB SITE (THE “MATERIALS”) FOR ANY PURPOSE.

THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON-INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.

References