0

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 Constraint 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?

3
  • Just check sysindexes too. I am not sure, but worth a try. Commented Mar 18, 2011 at 12:43
  • If there's definitely no other object in the database with that name (I hope you've been searching sys.objects based on just name at this point), open a ticket with MS. Commented Mar 18, 2011 at 13:31
  • Yes, there's definitely not one single object with the name. Commented Mar 18, 2011 at 13:38

1 Answer 1

2

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')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.