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
 General SQL Server Forums
 New to SQL Server Programming
 detecting dml in ins,upd,del all in one trigger

Author  Topic 

hello.d3b
Starting Member

16 Posts

Posted - 2009-08-07 : 13:51:43
Hi,

i have a common trigger for insert, update and delete routines.

Apart from refering to the existence of records in inserted and deleted virtual tables is there any other way to validate whether it is the insert or delete or update statement which fired the trigger?

I need to validate something like this :

if insert then do something
if delete then do something
if update then do something

kindly help.



deb

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-07 : 14:02:31
I think the most straight forward way is by using those virtual tables as you indicated. Is there a problem doing it that way?


Be One with the Optimizer
TG
Go to Top of Page

hello.d3b
Starting Member

16 Posts

Posted - 2009-08-07 : 14:08:25
i wanted to know if there is any keyword like in oracle to determine which dml fired the trigger.
checking record availability in virtual tables is a little clumsier

deb
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-07 : 16:43:46
agreed - but No, the only thing you can do is check if a particular column or columns have been updated by UPDATE() or Columns_Updated(). But not a generic thing to see what event fired the trigger.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -