Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6365491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:17:59+00:00 2026-05-25T00:17:59+00:00

A same table foreign key constraint in my database is not accessible. I can

  • 0

A same table foreign key constraint in my database is not accessible. I can not drop it, disable it, add it back, … How do I remove it and re-add it?

Note: I have several versions of my database all created with the same script. Only in one I see this behavior. In others, this key is easily added and removed.

Many thanks. Here is some scripts I ran and the result:

At some point in the past i ran the following script:

ALTER TABLE Recipe
ADD CONSTRAINT FK_Recipe_DuplicateOfRecipeId_Recipe_Id FOREIGN KEY (DuplicateOfRecipeId)
    REFERENCES Recipe (Id) ;

now running

ALTER TABLE Recipe DROP CONSTRAINT  FK_Recipe_DuplicateOfRecipeId_Recipe_Id 
results in the following error:
'FK_Recipe_DuplicateOfRecipeId_Recipe_Id' is not a constraint.

and running

ALTER TABLE Recipe NOCHECK CONSTRAINT FK_Recipe_DuplicateOfRecipeId_Recipe_Id
results in: Constraint 'FK_Recipe_DuplicateOfRecipeId_Recipe_Id' does not exist.

so i run

alter table Recipe ADD CONSTRAINT FK_Recipe_DuplicateOfRecipeId_Recipe_Id FOREIGN KEY (DuplicateOfRecipeId) REFERENCES Recipe (Id);

and i get:

The ALTER TABLE statement conflicted with the FOREIGN KEY SAME TABLE constraint "FK_Recipe_DuplicateOfRecipeId_Recipe_Id". The conflict occurred in database "CrawlerDB", table "dbo.Recipe", column 'Id'.

so I run:

select COUNT(*) from sys.objects where name = 'FK_Recipe_DuplicateOfRecipeId_Recipe_Id'
select COUNT(*) from sys.all_objects where name = 'FK_Recipe_DuplicateOfRecipeId_Recipe_Id'
SELECT COUNT(*) FROM sys.foreign_keys where name = 'FK_Recipe_DuplicateOfRecipeId_Recipe_Id'

and all 3 return nothing.

Whats going on and how do I fix it? I need to access this object, remove it and add it back.
Many thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:18:00+00:00Added an answer on May 25, 2026 at 12:18 am

    I’m guessing that your master database is corrupted. You’d probably be best suited by rebuilding it.

    However, as a workaround, you could try this:

    1. Duplicate your foreign key into a non-FK column

      ALTER TABLE Recipe ADD DuplicateOfFK INT

    2. Copy all your FK data to the duplicate

      UPDATE Recipe SET DuplicateOfFK = DuplicateOfRecipeId

    3. Drop the Foreign Key column

      ALTER TABLE Recipe DROP COLUMN DuplicateOfRecipeId

    4. Go backwards.

      ALTER TABLE Recipe ADD DuplicateOfRecipeId INT

      UPDATE Recipe SET DuplicateOfRecipeId = DuplicateOfFK

      ALTER TABLE Recipe DROP COLUMN DuplicateOfFK

    5. Add the constraint back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing primary key and foreign key that references same table.
The usual way of setting a foreign key constraint is to choose which table
Does MS Access 2007 support internal foreign keys within the same table?
Can a trigger for a table can be applied for tracking in same table?
How can I set parent-child relation on same table? Id int, title string, ParentId
I have a many to many table setup in my mysql database. Teams can
I have a table, ProductSupportArticles: ProductSupportArticleID int NOT NULL <primary key> ParentArticleID int NULL
I've created a Companies table with foreign key ( ParentCompaniesId ) to the primary
I have a relational table containing a foreign key in which there is no
I have a table and two databases which have the same table, but one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.