tsql - SQL Transact - Trigger on an INSERT into a specific table -
i need write sql transact trigger execute simple task if insert
called if insert
modify table t
(so if insert t (...) values (...)
.
i'm using if (update[col])
trigger performing task obliviously, isn't calls when row created , need manage case too.
i've seen event_date
, after insert
don't know how perform if insert
operates specific table t
.
can have example how this?
this pseudo-code:
if (new row insert on t) or (t.c updated) { task }
from manual https://msdn.microsoft.com/en-gb/library/ms189799.aspx
-- sql server syntax trigger on insert, update, or delete statement table or view (dml trigger) create trigger [ schema_name . ]trigger_name on { table | view } [ <dml_trigger_option> [ ,...n ] ] { | after | instead of } { [ insert ] [ , ] [ update ] [ , ] [ delete ] } [ append ] [ not replication ] { sql_statement [ ; ] [ ,...n ] | external name <method specifier [ ; ] > }
so need
create trigger mytrigger on mytable insert, update // stuff
or if want write update , insert seperately
create trigger mytrigger_update on mytable update // stuff update create trigger mytrigger_insert on mytable insert // stuff insert
Comments
Post a Comment