I need to write an Insert, Update Trigger on table A which will delete all rows from table B whose one column (say Desc) has values like the value inserted/updated in the table A's column (say Col1). How would I go around writing it so that I can handle both Update and Insert cases. How would I determine if the trigger is executed for an update or insert.
+6
A:
If it's MS SQL Server, then IF EXISTS (SELECT * FROM DELETED)
tells you if it's an update. You only have rows in DELETED on update, bt there are always rows in INSERTED.
Look for "inserted" in CREATE TRIGGER
gbn
2009-04-12 08:03:23
Thanks for the reply - Got everything I needed to know. I agree I must have added that I need to do it for SQL Server.
MSIL
2009-04-12 08:08:56