Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SP for Cascade Deletes
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00397669
Message ID:
00398089
Views:
19
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform