How to execute trigger sqlserver

0

How can I perform a trigger on unit tests. I have a trigger I have a trigger as an example:

    ***-- Create one trigger with two inserts:***
create trigger trg_I_Table_1 
ON Table_1 
FOR INSERT
as
insert into Table_2 (Col_1, Col_2, Col_3) select Col_1, Col_2, Col_3 
from inserted
insert into Table_3 (Col_1, Col_2, Col_3) select Col_1, Col_2, Col_3 
from inserted
go
    
asked by anonymous 18.04.2016 / 20:12

1 answer

2

The trigger is executed automatically before or after the insert, delete, or update commands are executed. I do not know of another way to execute a trigger without executing these commands.

CREATE OR REPLACE TRIGGER department insert update   
BEFORE INSÈRT OR UPDATE ON department   
FOR EACH ROW   
DECLARE   dup flag INTEGER;   
BEGIN    
NEW.dept name := UPPER(:NEW.dept name);  
END;

You need to tell which commands trigger the trigger, in this example we have the insert and update commands. The moment that will be triggered, in the case would be BEFORE INSERT or UPDATE department and finally the necessary updates.

    
05.05.2016 / 06:00