トリガー:削除時にトリガーして情報を記録する

1037 ワード

-- delete 

CREATE TRIGGER trig_delete_mzy_request
   ON mzy_request  -- 
   for delete
AS 
BEGIN

    DECLARE @IP_Address varchar(50)=''; 

    SELECT TOP 1 @IP_Address=client_net_address -- IP 
    FROM sys.dm_exec_connections  
    WHERE session_id = @@SPID; 
  --  
  insert into mzy_request_delete_log select *,GETDATE() as DeleteTime,@IP_Address AS IpAddress from Deleted;  

END

感謝:https://blog.csdn.net/cb168/article/details/8457195
転載先:https://www.cnblogs.com/dzw159/p/8979922.html