I need a script to add/update records from one server table to another

  • Help, I'm the new DBA and I've been tasked with doing the following.

    This is the scenario!

    I have a SQL server database on one server (lets call it Database_A), and another one on different server (Database_A_Hist that's exactly the same in structure).

    Database_A_Hist is a dedicated history SQL server database that contains the same information as Database_A and every night a job is supposed to run that will first check that the information in Database_A matches Database_A_Hist. If not then the affected information is added or updated to the Database_A_Hist server.

    I can do this easily in VB6, but they need this done on the servers. Does anyone have a SQL script that will do this?

    Thanks

  • As you have posted this in the dts forum, the functionality you require is a task known as 'Data Driven Query Task'.

    Basically this is a task that perform updates, inserts and deletes driven by the data in two tables. I have never tried to create a task that performs at database level, but it may be possible. I.E If there are missing records in the destinationtable , it will perform an insert.

    Loads of articles out there to show how this is done. But..... Can be reaaaal slow.

    If you want speed and more control over the process I would suggest a third party product like Emarcadero.


    ------------------------------
    The Users are always right - when I'm not wrong!

  • Hi,'

     

    Do u want to do this for one table or for number of tables.

    if u have to do this for all the tables then use variables and query to sysobjects and move a cursor with nested query.

    for one table

    if u have a primary then  u can use a nested query that will check if data exists then no insert if not then insert the data into second server from server one.

    I faced this senerio in my OLAP server DTS(ETL) from production server to OLAP Server.

    from

    Killer

Viewing 3 posts - 1 through 2 (of 2 total)

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