在SQL Server 2005中无法删除约束,“无法删除约束。查看先前的错误” [英] Unable to drop constraint in SQL server 2005, "Could not drop constraint. See previous errors"

查看:792
本文介绍了在SQL Server 2005中无法删除约束,“无法删除约束。查看先前的错误”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在数据库表上删除约束,例如:

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

推荐答案

找到了一种对此进行排序的方法,尽管我不明白为什么这样做是必要的。

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

然后完成删除操作

仍然欢迎任何对此必要原因的评论

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

这篇关于在SQL Server 2005中无法删除约束,“无法删除约束。查看先前的错误”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆