• Mansfield (4/28/2013)


    I would set up the SSIS package to insert into a staging table first. Then use a SQL task to check for references in the staging table that does not yet exist, and insert the references. Use something like a left outer join check:

    insert into reference_table (reference_id, reference_description)

    select s.reference_id, 'some description'

    from staging_table s

    left join reference_table r on r.reference_id = s.reference_id

    where r.reference_id is null

    After the references are resolved, copy from the staging table to the actual table being loaded.

    From my experience WHERE NOT EXISTS always perfoms better, at least not worse, than LEFT JOIN with IS NULL check:

    insert into reference_table (reference_id, reference_description)

    select s.reference_id, 'some description'

    from staging_table s

    WHERE NOT EXISTS (select * from reference_table r

    where r.reference_id = s.reference_id)

    _____________
    Code for TallyGenerator