Wednesday, 16 May 2007
Sql Triggers for Dummies
i always found the syntax of SQL triggers very difficult to remember, so i'm just posting a sample one here. it performs a cascade delete on a table that doesn't have referential integrity (because there are 2 potential foreign keys).
ALTER TRIGGER [dbo].[Table1CascadeDeleteTable2]
Wednesday, 16 May 2007 18:36:37 (GMT Daylight Time, UTC+01:00) Database
declare @Ref int;
SELECT @Ref = Ref FROM Deleted;
delete from Table2 where Ref = @Ref;