Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 INSERT, UPDATE, DELETE trigger

Author  Topic 

dohamsg
Starting Member

22 Posts

Posted - 2012-08-01 : 13:56:34
Hi,
If I create a trigger like:

CREATE TRIGGER tr_AccountBalance
ON [dbo].[JournalEntryLine]
AFTER INSERT, UPDATE, DELETE
AS
...

Q/ Is it possible to know which event was triggered : INSERT, UPDATE or DELETE?

Thanks.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-08-01 : 14:12:02
If INSERTED isn't empty and DELETED is empty then event=insert.
If DELETED isn't empty and INSERTED is empty then event=delete.
If both INSERTED and DELETED are not empty then event=update.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -