Create trigger to insert records into table in different server

  • Hello Friends,

    I have a business requirement to construct a trigger so whenever a new record is added to the table in the database, the trigger would fire to append those records to the equivalent tables in the database on another server

    Also, the same trigger should be applied to existing records being edited, or where records are being deleted.

    Could someone please provide a sample solution which I use as a starting point ?

    Thanks and Regards,

    Paul

  • What about replication?

    -- Gianluca Sartori

  • Gianluca Sartori (3/11/2011)


    What about replication?

    Hi Gianluca,

    Thanks for your reply. Could you please explain what you meant by replication as I am very new to SQL ?

    Regards,

    Paul

  • I meant if you could just briefly explain how this can be achieved through replication.

  • I mean that you can replicate tables to remote sql servers:

    http://msdn.microsoft.com/en-us/library/ms151198.aspx

    Obviously, if the target server is not MS SQL Server, this is not an option.

    -- Gianluca Sartori

  • Hello,

    Can anyone please help me in this regard. I don't have any idea about replication and would like to give this a try using triggers.

    I have a business requirement to construct a trigger so whenever a new record is added to the table in the database, the trigger would fire to append those records to the equivalent tables in the database on another server

    Also, the same trigger should be applied to existing records being edited, or where records are being deleted.

    Could someone please provide a sample solution which I can use as a starting point ?

    Thanks and Regards,

    Paul

  • I would strongly advise against doing this in a trigger.

    What would happen if the other server was unavailable? Would you want your original update to fail as well, or would you want it to succeed and then apply it to the other server later on?

    Gianluca gave you good advice... look into replication.

    Just Google SQL Server Replication, and you will get a mountain of articles explaining it.

  • Ian Scarlett (3/14/2011)


    I would strongly advise against doing this in a trigger.

    What would happen if the other server was unavailable? Would you want your original update to fail as well, or would you want it to succeed and then apply it to the other server later on?

    Gianluca gave you good advice... look into replication.

    Just Google SQL Server Replication, and you will get a mountain of articles explaining it.

    Hi Ian,

    Thanks a lot for your reply. I realized what you have mentioned and have tried to read and follow the articles on replication. But as this concept is new to me, I don't know how to start with this. Also, isnt replication usually performed by DBA's ? I am quite new to SQL and have no idea how to use replication for this requirement.

    Would it be possible for you to give some insight into achieving this requirement with replication ? Even some hint or a starting point would be good enough and then I can build up on that.

    Thanks and Regards,

    Paul

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply