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 2000 Forums
 SQL Server Development (2000)
 clarification regarding triggers

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-04-20 : 07:52:01
ravi writes "Hi,

The following is my trigger:

create trigger sample
on emp1
for insert, delete, update
as begin
print ('sample trigger')
end


Is there any possibilty of finding the type of action(insert, update, delete) that has invoked the above trigger(sample) within the trigger. something similer to event handling.

it's very important task, can any one help.

Thanks in advance"

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-04-20 : 08:00:47
update(column_name) will tell you if the column has been updated,

records are stored in:

for insert = inserted
for update = deleted (old data) and inserted (new data)
for delete = deleted

usually, i check for the unique key if i'm differentiating insert from update, for delete, i compute the column values using columns_updated()

check this two functions in BOL


To be simple: make separate triggers for insert, delete and update

HTH

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -