Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 DELETE statement conflicted with REFERENCE content

Author  Topic 

edyl
Starting Member

35 Posts

Posted - 2011-06-22 : 15:38:06
Hello Everyone,
I was trying to delete rows from a Customer table but ran into this error:

quote:

The DELETE statement conflicted with the REFERENCE constraint "FK_Customer_to_Product". The conflict occurred in database "CoMart", table "dbo.ProductSale", column 'FKCustomer'.



As suggested in many of the posts, I went ahead and first deleted the corresponding rows from the referenced (child) table – ProductSale.

After that I try again to delete the rows from the Customer table(parent) it still gives me the exactly same error message.

I deleted the rows from the ProductSale table only as the error suggests that the constraint problem occurred only in this table. Do the rows need be deleted from all the tables that references the Customer table even though the error only points out to one?

Btw what does it mean by REFERENCE constraint “FK_Customer_to_Product"? Is this the name of the constraint? Because, I don’t see that name in the Object Explorer when I expand the ProductSale table. I only see the column FKCustomer.

All suggestions, recommendations greatly appreciated.

Thanks in Advance

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-22 : 15:47:28
If you expand the Keys folder under the table you'll see the foreign key constraints.

And yes, for each table that references Customer via a foreign key, you'll have to delete any (child) rows that have the same key as what you want to delete from Customer.
Go to Top of Page

edyl
Starting Member

35 Posts

Posted - 2011-06-22 : 16:08:13
Thanks!
Go to Top of Page
   

- Advertisement -