We receive bulk data from our customers in a spread sheet. I loaded them in a temporary table as of now. I tried to normalize the data and create a parent table and each parent to have 4 or 5 child rows. Is there a way to insert all the parents and their children using queries? I am using MSSQL

  • Is there a reason why you want to do it using a single query? You can use multiple queries within a SQL transaction to attain atomicity. Jan 3, 2012 at 19:42
  • Sorry about that. It need not be a single query.. I just want something where I dont want to write an application to do that.
    – franklins
    Jan 3, 2012 at 19:55

1 Answer 1


Once you have normalised you need 2 queries, one to load parents then one to load children (you can only insert into 1 table at a time using sql)

It sounds like you do this ofter, so why not create a file with the sql commands that you use, and each time you do this task open the file up in your databases sql editor window and run (may-be first modifying) these commands. If it always the same sort of task, you could write a script that connects to the database and runs the sql statments you need - then it is a one click or command task.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.