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.
From stackoverflow
-
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
MSIL : 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.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.