Unable to remove constraint in SQL Server 2005 "Unable to remove constraint. See Previous Errors"

I am trying to remove a restriction on a db table, for example:

ALTER TABLE MyTable drop CONSTRAINT FK_MyTable_AnotherTable 

But execution just starts and starts. If I stop, I see:

 Msg 3727, Level 16, State 0, Line 2 Could not drop constraint. See previous errors. 

Web search returns multiple pages, but note that the restriction is correctly named and I am trying to remove it with the correct name

+4
source share
4 answers

A sorting method was found, although I do not understand why it was necessary.

Removed the restriction by first disabling it:

 ALTER MyTable NOCHECK CONSTRAINT FK_MyTable_AnotherTable 

Then the drop ends in a fine

Still welcome any comments for the reason why this is necessary

+2
source

Make sure you have not reset the limit yet, for example:

 SELECT OBJECT_ID('FK_MyTable_AnotherTable') 

If this returns null , your restriction no longer exists. This explains the error message.

+1
source

I had the same problem on SQL Server 2008 R2 , I solved the problem using the line below, I hope it will work for someone else :)

  Alter Table [Table Name] DROP Column [Column Name] 
+1
source

I had the same problem.

The reason is because I made a mistake in the cursor instruction, which repeated some restriction that I had to discard. Therefore, this error occurred when the restriction was deleted in the same transaction . Then I rolled back and checked if it existed: it did (of course, after the rollback!).

Check if it really exists at the time of reset.

0
source

Source: https://habr.com/ru/post/1306242/


All Articles