How do I split import data from excel to 2 tables?

  • How do I import data into 2 tables from one excel file where table 2's related records only exists if data exists?

    :from this excel file

    name, address

    'bob' ''

    'fred' '123 street St.'

    e.g. I want the import to look this

    :TABLE 1

    id,name

    1 bob

    2 fred

    :TABLE 2

    id, table1ID, address

    1,2,999 abby st.

    Thanks for any assistance!

  • Two ways that I can think of are:

    1. import the data into a staging table that has an identity column and then run two insert statements to split the data into two tables.

    The first one would add all the names to the names table. The second would add just the address records to the address table that have a value provided.

    2. Using an SSIS package, there is a data transformation that can be used to split the source data into two destination tables. You then would have to aply some logic to the second transformation to skip the entries that have not data.

    Dave Novak

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

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