A simple DTS package?

  • I need to do a simple update. I don't think it's too complicated, but I'm not sure how to do it. Here it is:

    1. Grab a set of records from table1 that don't match table2. (the inconsistancies)

    2. Update table2 records with the table1 recordset. (make the tables match)

    3. insert a log record in table3 for every update that happened.

    why is this hurting my brain - should it be this hard?

  • Here is a query that will identify differences:

    SELECT *

    FROM table1 t1

    INNER JOIN table2 t2 ON t1.[ID] = t2.[ID]

    WHERE t1.column1 <> t2.column1

    Here is a query that will update the differences:

    UPDATE t2 SET column1 = t1.column1

    FROM table1 t1

    INNER JOIN table2 t2 ON t1.[ID] = t2.[ID]

    WHERE t1.column1 <> t2.column1

    There are many ways to log the updates. You can create a trigger to save each change made to table2 in table3. You could save the results of the first query (in a temp table) and then insert the appropriate info into table3 before or after the update runs.

    I hope this helps.

    Robert W. Marda

    SQL Programmer

    bigdough.com

    The world’s leading capital markets contact database and software platform.

    Robert W. Marda
    Billing and OSS Specialist - SQL Programmer
    MCL Systems

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

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