Dan*_*ell 6 sql sql-server constraints alter-table
我试图在数据库表上删除约束,例如:
ALTER TABLE MyTable drop CONSTRAINT FK_MyTable_AnotherTable
Run Code Online (Sandbox Code Playgroud)
但执行只是运行并运行.如果我停止它,我看到:
Msg 3727, Level 16, State 0, Line 2
Could not drop constraint. See previous errors.
Run Code Online (Sandbox Code Playgroud)
Web搜索会抛出各种页面,但请注意约束已正确命名,我尝试使用正确的名称将其删除
我在SQL Server 2008 R2上遇到了同样的问题,我用下面的代码解决了我的问题,希望它也适用于其他人:)
Alter Table [Table Name]
DROP Column [Column Name]
Run Code Online (Sandbox Code Playgroud)
找到了一种方法来对此进行排序,尽管我不明白为什么有必要。
已经能够通过首先禁用它来删除约束:
ALTER MyTable NOCHECK CONSTRAINT FK_MyTable_AnotherTable
Run Code Online (Sandbox Code Playgroud)
然后下降就完成了
仍然欢迎任何关于为什么这是必要的评论