I need determine each of this this 3 commands in trigger [UPDATE,DELETE,INSERT].For last 2 I do next:
IF EXISTS (SELECT * FROM inserted)
BEGIN
END
ELSE IF EXISTS (SELECT * FROM deleted)
BEGIN
END
How can I get updating rows?
Thanks.
Not exactly sure what you’re trying to accomplish, but you can test if it’s an
UPDATEif bothinserted(values after update) anddeleted(values before update) exist. From the documentation:Thus, if
insertedexists but notdeleted, it’s anINSERT; ifdeletedexists but notinserted, it’s aDELETE; if they both exist, it’s anUPDATE.