Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SP for Cascade Deletes
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00397669
Message ID:
00398089
Vues:
17
Kevin,

First, welcome to the Forum!

SQL Server 6.5 and 7.0 do not support cascading RI. This is a feature that has been included in SQL Server 2000.

You'll have to use triggers to achieve the same functionality. On the parent table, create a DELETE trigger that cascades the delete to the child table

CREATE TRIGGER trigger_name FOR DELETE on parent_table
AS
DELETE FROM child_table
WHERE fkid IN (SELECT PK FROM deleted)
GO -- if you're using QA or OSQL

"deleted" is a special table that exists only within the scope of the trigger and contains all the rows that were removed from the table during the execution of a DELETE.

You'll probably want to checkout the CREATE TRIGGER topic in the SQL Server Books Online (BOL).

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform