0

I have to delete a record which is referenced in at lease 27 tables and that is PK i want to delete that Row.

I have tried for it but still i can't get proper result.

Plz help if possible.

Thankx & Regards,

Maru Akashkumar J.

Tony Hopkinson
  • 20,172
  • 3
  • 31
  • 39
  • Could you please post your delete statement/table definitions? – Bridge Mar 01 '12 at 10:02
  • You've tried what? If the foreign keys are set up and have cascading delete set, all you have to do is delete it from the table that is being referenced. That's the point of it. – Tony Hopkinson Mar 01 '12 at 10:03

1 Answers1

0

You have to specify the delete/update behaviour when defining a foreign key constraint for the child table. For you to able to delete rows in your parent table, all the foreign key containts in all your 27 child tables would have to cascade on delete.

Have a look here : SQL Script to alter ALL Foreign Keys to add ON DELETE CASCADE

But i think there is a good reason, why you should not be able to delete records if there are plenty of dependent records elsewhere.

Community
  • 1
  • 1
Mithrandir
  • 24,869
  • 6
  • 50
  • 66