Sunday, February 19, 2012

FOR and AFTER

Someone pls enlighten me...
I understand that FOR TRIGGERS would be executed concurrently as the table is being updated/inserted/deleted
&
AFTER TRIGGER would only be executed after the UPDATE/INSERT/DELETE operation has been completed...am i right?I never heard of FOR TRIGGERS. I only know about
BEFORE TRIGGER (not supported by MSSQL, as far as I know)
AFTER TRIGGER
INSTEAD OF TRIGGER

Where did you hear about FOR triggers ?|||ok sorry i didn't mean FOR triggers..

what i meant was ..whats the difference between the following 2.

ALTER TRIGGER SendMsgs ON asiapac702_test.dbo.tblCustServiceHistoryHdr FOR UPDATE
AS...

ALTER TRIGGER SendMsgs ON asiapac702_test.dbo.tblCustServiceHistoryHdr AFTER UPDATE
AS...|||Ok, now I get it.

As far as I can understand from the documentation, FOR and AFTER are synonyms, from a syntax point of view.

I did some testing, and found no differences between

create trigger tai_t on t FOR insert as begin select 1 end
create trigger tai_t2 on t AFTER insert as begin select 1 end

Probably this has something to do with being ANSI/ISO or whatever compliant.

No comments:

Post a Comment