Detecting Trigger Type from Table which have Common Triger(Insert ,Update,Delete )

Posted by Rk123456 under Sql Server on 4/11/2010 | Views : 1386 | Status : [Member] | Replies : 1
Craete trigger tg_insert_update_delete on
people FOR INSERT,UPDATE,DELETE
As
begin

if (select count(*) from inserted)>0
begin
if (select count(*) from deleted)>0 --update
begin
print 'Update'
end
else
begin
print 'insert' --insert
end
end
else if (select count(*) from deleted)>0 -- only delete
begin
print 'delete'
end

end

--Now Execute

Insert into People values(1)

Update people set a=190 where a=2

Delete from people where a=190




Responses

Posted by: Vuyiswamb on: 4/12/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
I cant understand your Problem. Can you please explain in detail

Thank you for posting at Dotnetfunda
[Administrator]

Rk123456, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response