Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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

share|improve this question
    
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. –  darwindeeds Jan 3 '12 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 '12 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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