Tuesday, 20 August 2013

Importing Excel data into multiple SQL tables

Importing Excel data into multiple SQL tables

I have an excel document that I need to import into SQL. I have 3 existing
SQL tables: account, account_type, and sub_type. For each row in the
excel, I need to insert a new row into account, with a foreign key linking
to a new row in the account_type, with a foreign key linking to a new row
in sub_type.
So account links to account_type links to sub_type. Each row of the excel
sheet has data that will populate the three different tables.
I am thinking there should be a way to do this with some kind of loop in
the query where I can get the last inserted ids and all that jazz, but my
SQL knowledge isn't to the point of loops and functions and all that
advanced stuff.
Appreciate any help on how to sort this out!
edit: I am trying to get it all done in one sql query.

No comments:

Post a Comment