Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to drop constraint in SQL server 2005, "Could not drop constraint. See previous errors"

I'm trying to drop a constraint on a DB table, something like:

ALTER TABLE MyTable drop CONSTRAINT FK_MyTable_AnotherTable

But the execution just runs and runs. If I stop it I see:

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

Web search throws up various pages but note that the constraint is properly named and I am trying to remove it using the correct name

like image 422
DannykPowell Avatar asked Apr 07 '10 13:04

DannykPowell


2 Answers

I was having the same issue on SQL Server 2008 R2, I solved my problem with below line hopefully it will work for someone else as well :)

    Alter Table [Table Name]
    DROP Column [Column Name]
like image 118
Zeeshan Ajmal Avatar answered Nov 15 '22 08:11

Zeeshan Ajmal


Found a way to sort this, although I don't understand why it was necessary.

Have been able to drop the constraint by disabling it first:

ALTER MyTable NOCHECK CONSTRAINT FK_MyTable_AnotherTable

The drop then completes fine

Would still welcome any comments on the reason why this is necessary

like image 23
DannykPowell Avatar answered Nov 15 '22 08:11

DannykPowell