Click here to Skip to main content
15,922,007 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,

we having two table PRODUCT and ORDER
ORDER reference product primary key,
when we delete order rows foreign key conflict arise,
how to make when we delete order rows corresponding PRODUCT ROW also delte?

thanks and regards
vinay
Posted

you need to use on delete cascade:

http://msdn.microsoft.com/en-us/library/aa933119%28v=sql.80%29.aspx[^]

hope it helps :)

for further queries comment here!
 
Share this answer
 
Comments
Espen Harlinn 29-Oct-11 7:56am    
5'ed - right and a bit scary, let's hope OP known what he is doing ...
Uday P.Singh 29-Oct-11 11:46am    
thanks for 5! , I want to know what's the scary part here?
Hi Vinayfirstblock,

It's very strange that deleting a row in detail table causes an error ! if you told that when you delete a row from PRODUCT and you got some errors I wouldn't wonder but now it's very strange that you got this error. May be there is another table that has detail information about the ORDER info. Anyway try to set all the relationships with ORDER table and set their Delete Rule to Cascade.

Hope It Helps.
 
Share this answer
 
Comments
Espen Harlinn 29-Oct-11 7:58am    
5'ed, because it will work - may lead to unintended loss of data if OP is not careful ...
Amir Mahfoozi 29-Oct-11 9:06am    
Thank you Espen
First delete row from table which has refrenced as foreign key.

Then delete it(row) from table which has primary key Constraint.
 
Share this answer
 
Comments
Espen Harlinn 29-Oct-11 8:00am    
That's reasonable and certainly didn't deserver a downvote ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900