IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[pub_message_delete]') AND type = 'TR')
DROP TRIGGER [dbo].[pub_message_delete]
GO
CREATE trigger [dbo].[pub_message_delete] on [dbo].[pub_message] for delete as
begin
 

    
    insert into pub_message_history(msg_cmpid,msg_mpid,msg_text,msg_senddate,msg_type,msg_target,msg_cuid,msg_sendtimes)
select msg_cmpid,msg_mpid,msg_text,msg_senddate,msg_type,msg_target,msg_cuid,msg_sendtimes 
from deleted  

    
end