shapper
3/20/2007 11:04:00 AM
On Mar 20, 10:28 am, "Tom Moreau" <t...@dont.spam.me.cips.ca> wrote:
> You would use ON DELETE CASCADE for those tables that depend on Documents.
> You would use ON DELETE RESTRICT for those that depend on Users.
>
> --
> Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> ."shapper" <mdmo...@gmail.com> wrote in message
>
> news:1174386199.707546.122540@l77g2000hsb.googlegroups.com...
> Hello,
>
> I have 2 tables: Users and Documents.
> Then I have many other tables which are related with FKs to Users and
> Documents.
>
> I want to delete all the dependent records on all tables when I delete
> a document in Documents table. However, I don't want that to happen
> when I delete a user in Users table.
>
> How can I do this with CASCADE DELETE?
>
> And should I use a trigger instead?
>
> I am using SQL 2005.
>
> Thanks,
> Miguel
But the ON DELETE CASCADE and ON DELETE RESTRICT are table definitions
or should I place that in a stored procedure. I am not getting it.
But if a table have 2 FK: one related with documents and one to users.
If I delete a user I don't want the record to be deleted but if i
delete a document I want the record to be deleted.
Thanks,
Miguel