September 2010
Intermediate to advanced
1704 pages
111h 8m
English
A cascading delete is relatively simple to create. Listing 30.6 shows a cascading delete trigger for the customers table.
SQL Server 2000 added a feature that allows you to define cascading actions on a FOREIGN KEY constraint. When defining the constraints on a table, you can use the ON UPDATE CASCADE or ON DELETE CASCADE clause, which causes changes to the primary key of a table to cascade to the related foreign key tables. Refer to Chapter 26, “Implementing Data Integrity,” for further information on this option.
Listing 30.6 A Cascading Delete for the customers Table

The following DELETE statement deletes the row for ...