||SQL Server Tips by Gama and Naughter
Cascade delete requires one trigger for table [Tbl A] that will
delete the related columns from table [Tbl B].
CREATE TRIGGER "[[Tbl A DTrig]" ON [Tbl
A] FOR DELETE AS
SET NOCOUNT ON
/* * CASCADE DELETES TO '[Tbl B]' */
DELETE [Tbl B] FROM deleted, [Tbl B] WHERE deleted.[col A] = [Tbl
The code will
try to delete all related rows in table [Tbl B].
Let us try the
DELETE [Tbl A] WHERE [col
By checking the
contents of table [Tbl B] it is obvious that the trigger worked.
The above book excerpt is from:
Turbocharge Database Performance with C++ External Procedures
Joseph Gama, P. J. Naughter