SQL Server Trigger switching Insert,Delete,Update

后端 未结 5 1902
慢半拍i
慢半拍i 2021-02-09 01:39

Hello is possible to switch between DML commands/operations (Insert,Delete,Update) on Trigger Body?, I try to snippet some T-SQL for understand me better :

CREA         


        
5条回答
  •  [愿得一人]
    2021-02-09 02:18

    I think the general way to do this is to create a trigger for each action, like so:

    CREATE TRIGGER INSERT_ON_TABLEA   
    ON  TABLEA   
    AFTER INSERT 
    AS 
    BEGIN    
    SET NOCOUNT ON;    
    -- INSERT ON AUX TABLEB
    END
    GO
    
    CREATE TRIGGER DELETE_ON_TABLEA   
    ON  TABLEA   
    AFTER DELETE
    AS 
    BEGIN    
    SET NOCOUNT ON;    
    -- DELETE ON AUX TABLEB
    END
    GO
    

提交回复
热议问题