Need help inserting records into tables

  • 3 tables exist which have one field in common. During a bi-annual file import a program runs against the file and inserts new records into one table, but doesn't popluate the other two because they were created after the program was written. I don't know programming so I can't fix the program. I'm trying to write a sql script to look for any new records (which I can do based on one of the fields in the newly populated table) and then insert new records into the other two tables, only duplicating the ID in each to match the ID in the first table, and then add additional fields based on other criteria. Any help would be fantastic!

  • If you know how to write a SELECT query to get what you want then you just do an

    INSERT INTO tblNameHere (columnlist) YOURSELECTSTATEMENT

    Just make sure you account for previous records their, something like

    SELECT COLUMNLIST

    FROM tbl1

    LEFT JOIN tbl2

    ON tbl1.PKID = tbl2.FKID

    WHERE tbl2.FKID IS NULL

    will eliminate the items already in you table from being selected from tbl1.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

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

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