开发者

SQLServer: How to drop corrupted Foreign Key Constraint

I have a corrupted Foreign Key Constraint in one of our databases.

I can't drop it - because it does not exist. It does not exist in sys.sysobjects and sys.objects. SQLServer Management Console does not list it as well,

Yet, I can't recreate the Foreign Key Constra开发者_如何学Goint because it already exists in the schema (error: an object with the same identifier does already exist).

How can I fix that? Which metadata tables are responsible for that?


The only thing I can think of is if it's somehow doing a case-sensitive match and you're passing in a name with different case than what the server has stored. Try this:

select fk.[name]
from sys.foreign_keys fk
inner join sys.objects o
   on fk.[referenced_object_id] = o.[object_id]
where lower(o.[name]) = lower('your table here')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜