SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 INSERT, UPDATE, DELETE trigger
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dohamsg
Starting Member

22 Posts

Posted - 08/01/2012 :  13:56:34  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 08/01/2012 :  14:12:02  Show Profile  Visit webfred's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000