简体   繁体   中英

SQL insert trigger vs replication or stored procedure

I have 2 SQL Server tables that are linked via a link server connection. I have placed the following trigger on one table to fire as soon as a record is inserted into the one table and copies it across to my other table. However if the link should break for some reason or the other server goes down my trigger wont fire is its instantaneous only.

What would be the best recommendation to handle this situation?

ALTER TRIGGER [dbo].[trgAfterInsert] ON  [cms].[dbo].[HA_TRANSIT]
FOR INSERT
AS  
    INSERT INTO [10.230.1.56].[wfcdb].[dbo].[PunchDataHoneywell](card_number, identifier, name, surname, transit_date, terminal, direction, exported) 
       SELECT 
          card_number, identifier, name, surname, transit_date, terminal, direction, exported = '0'
       FROM inserted

Database replication is best way to synchronize two tables on different server. For mor detail go through : http://msdn.microsoft.com/en-us/library/ms151198.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM