updating data

  • I have 2 tables.

    Table A has existing records

    Table B has new records to be updated into Table A.

    However, I need to avoid duplication. What would be the best way to insert the data from table B into table A, but only if the data doesnt already exist in Table A. Is there a clause/function I can use?

    Thanks

    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!

  • You can use a non-correlated sub query in the WHERE clause with a focus on the keys.

    
    
    INSERT TABLE A
    SELECT
    FROM TABLE B
    WHERE TABLE B KEY NOT IN (SELECT TABLE A KEY
    FROM TABLE A)

    Edited by - RonKyle on 07/10/2003 11:26:35 AM

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

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