Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Foreign Key Constraints referencing the Same Table

Status
Not open for further replies.

yeagly21

Programmer
Dec 11, 2003
23
US
So I am running into a problem trying to create a delete script. The below error is what I am receiving:

DELETE statement conflicted with COLUMN SAME TABLE REFERENCE constraint

What I have noticed is that two fields within this TableA, one being the Primary Key, are set up to be constraints to one another. In case that didn't make sense.
(PK)TableA.Key_ID <--> (FK) TableA.Second_Key_ID.

I am trying to remove the record but receiving the above error. I have tried to update TableA.Second_Key_ID to null but I still receive the same error. Does anyone know a good way, within a script, to accomplish the delete on a row that has a constraint to itself.

A little additional information this table is a vendor created table so modifying the constraint at a table level is not possible solution.

Thanks for the help and if any additional information is needed let me know.

Yeagly
 
you could disable the contraint. Look up.

"constraints [SQL Server], disabling"

in BOL

- Paul
10qkyfp.gif

- If at first you don't succeed, find out if the loser gets anything.
 
Thanks Paul that was exactly what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top