Failed to drop primary key

Created by QNE Software Sdn bhd, Modified on Mon, 2 Aug, 2021 at 3:41 PM by QNE Software Sdn bhd

Scenario 

Upgrade Database encountered error ‘Failed to drop primary key …’

The table and foreign key constraint that causing this error could be different but the solution is same.

Before proceed to resolve error Failed to drop primary key, you must identify the ‘table’ and ‘foreign key constraint’ from the occurred errors.

In this example, the ‘table’ is ‘StockAccountPresets’ and the ‘foreign key constraint’ is ‘FK_StockAccountPresets_GLAccounts_SalesDiscountReturnAccountId’


 

 

Solution 

  1. Connect your database with SSMS (SQL Server Management Studio)

https://support.qne.com.my/a/solutions/articles/81000385373 

  1. Right-click your server instance in Object Explorer, and then select New Query

  1. Paste the following T-SQL code snippet into the query window:

---Replace TABLE_NAME with the table name stated in error---

---Replace FOREIGN_KEY_NAME with the foreign key constraint name stated in error---

ALTER TABLE [dbo].[TABLE_NAME] DROP CONSTRAINT [FOREIGN_KEY_NAME]

  1. Replace TABLE_NAME with the table name stated in error and
  2. Replace FOREIGN_KEY_NAME with the foreign key constraint name stated in error
  3. Based on the example error in scenario, my correct query will be like this:

ALTER TABLE [dbo].[StockAccountPresets]

DROP CONSTRAINT [FK_StockAccountPresets_GLAccounts_SalesDiscountReturnAccountId]

  1. Execute the query, fully exit QNE Optimum application and perform database upgrade again

** Learn How to rebuild and reorganize indexes

** Learn more about Azure Cloud

** Learn more about QNE Hybrid Cloud Software


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article