Go Back   CodingForums.com > :: Server side development > MySQL > Other Databases

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-07-2005, 03:03 PM   PM User | #1
neuron
New Coder

 
Join Date: Jul 2005
Location: GMT +7
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
neuron is an unknown quantity at this point
Unhappy Error deleting record due to FK constraint

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!
neuron is offline   Reply With Quote
Old 08-07-2005, 08:44 PM   PM User | #2
eak
Regular Coder

 
eak's Avatar
 
Join Date: Jun 2002
Location: Nashville, TN
Posts: 354
Thanks: 0
Thanked 26 Times in 26 Posts
eak is on a distinguished road
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.
__________________
eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."
eak is offline   Reply With Quote
Old 08-08-2005, 04:15 AM   PM User | #3
neuron
New Coder

 
Join Date: Jul 2005
Location: GMT +7
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
neuron is an unknown quantity at this point
Quote:
Originally Posted by eak
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?

Thanks a lot.
neuron is offline   Reply With Quote
Old 08-08-2005, 05:22 AM   PM User | #4
eak
Regular Coder

 
eak's Avatar
 
Join Date: Jun 2002
Location: Nashville, TN
Posts: 354
Thanks: 0
Thanked 26 Times in 26 Posts
eak is on a distinguished road
how can you not know what rows? its your database right?
__________________
eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."
eak is offline   Reply With Quote
Old 08-08-2005, 06:15 AM   PM User | #5
neuron
New Coder

 
Join Date: Jul 2005
Location: GMT +7
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
neuron is an unknown quantity at this point
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.
I wanted to know if there's an easier way.

Thanks a lot!
neuron is offline   Reply With Quote
Old 08-08-2005, 06:41 AM   PM User | #6
eak
Regular Coder

 
eak's Avatar
 
Join Date: Jun 2002
Location: Nashville, TN
Posts: 354
Thanks: 0
Thanked 26 Times in 26 Posts
eak is on a distinguished road
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.
__________________
eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."
eak is offline   Reply With Quote
Old 08-08-2005, 08:14 AM   PM User | #7
neuron
New Coder

 
Join Date: Jul 2005
Location: GMT +7
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
neuron is an unknown quantity at this point
Thanks a lot! I'll check it out.
neuron is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:41 AM.


Advertisement
Log in to turn off these ads.