...

View Full Version : Error deleting record due to FK constraint



neuron
08-07-2005, 04:03 PM
I'm getting an error in deleting a record from Customers table (or other tables such as Categories) in Northwind database of SQL Server, due to foreign key constraint. How can I solve it? Thanks a lot!

eak
08-07-2005, 09:44 PM
It sounds like there is a row in another table that needs the row your trying to delete. You could try deleting the referencing row(s) first then delete the record from the customers table.

It would help to see the table structure to be sure though.

neuron
08-08-2005, 05:15 AM
It sounds like there is a row in another table that needs the row your trying to delete.

Right. What if I dont know in advance which tables have that row? How can I play around with this? :rolleyes:

Thanks a lot.

eak
08-08-2005, 06:22 AM
how can you not know what rows? its your database right?

neuron
08-08-2005, 07:15 AM
I'm just testing with the classic Northwind db in SQL Server. Seems I need to study the whole db and check the related tables for deletion. :rolleyes:
I wanted to know if there's an easier way. :D

Thanks a lot!

eak
08-08-2005, 07:41 AM
I am unfamiliar with this Northwind db and I have never use SQL Server (even though I have it on CD somewhere...).
I know that you can find the reationships with MySQL with this: SHOW TABLE STATUS FROM your_db_name [like 'tabe_name'];

I don't know what the SQL Server command is for the same thing. I noticed MySQL does things a little differently from my time using Oracle.

neuron
08-08-2005, 09:14 AM
Thanks a lot! I'll check it out. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum