Monday, March 19, 2012

Deleting a record in multiple table

I want to delete a client record, and that record is in several tables. e.g.
A client who has a record in persoanl information table, and a record in the
address table.
Is there a quick way to delete them all?
Thanks,You can use the ON DELETE CASCADE option on your foreign keys. You
could implement the equivalent in a trigger also. Otherwise you'll have
to do a separate DELETE for each table.
David Portas
SQL Server MVP
--

No comments:

Post a Comment