开发者

SQL Server constraint not deleting

So, first off, we're using a history system where there's 开发者_运维知识库a history version of all of our tables. I'm adding a new column to a table, so I add it to both the dbo and the hist versions. I add a constraint that the default should be 0. However, I misspelled the column for the hist table. So, I add the correct one, and go to drop the incorrect one. However, it's saying The object 'DF__FCRelease__NumRe_125D4E50' is dependent on column 'NumRelease'. This is the constraint I mentioned above. I've tried deleting it though SQL, which claims it completes successfully, but the constraint remains. I've tried deleting it through the GUI, but it claims the object does not exist. Here's the SQL I attempted to use to delete the constraint:

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__FCRelease__NumRe__125D4E50]') AND type = 'D')
BEGIN
ALTER TABLE [hist].[FCRelease] DROP CONSTRAINT [DF__FCRelease__NumRe__125D4E50]
END

Any ideas?


This, I believe, is related to a similar question. So, I'll give you a similar answer.

You probably need rebuild your master database. I suspect that there is some corruption there that is causing this issue.

As a workaround, you could try removing the column, re-adding it, and then re-adding the constraint (a la here). That might fix the problem as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜