Migration of Data into table with dependencies

  • I have to migrate data into the table which has dependencies. I want to insert data into parent table by using Insert Into command. If I do that will it be inserted in child table as well?

    Is there a rule i should follow?

    Please advise

  • beginner123 (3/23/2011)


    I have to migrate data into the table which has dependencies. I want to insert data into parent table by using Insert Into command. If I do that will it be inserted in child table as well?

    Only if you have a trigger that does it; otherwise you'll have to do it yourself.

    Is there a rule i should follow?

    Please advise

    Keep it simple, and set-based.

    You might want to look into the OUTPUT clause of the insert statement.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • I am facing similar issues...Thank you so much.

  • beginner123 (3/23/2011)


    I have to migrate data into the table which has dependencies. I want to insert data into parent table by using Insert Into command. If I do that will it be inserted in child table as well?

    Is there a rule i should follow?

    Please advise

    Insert all the data into a staging table. Build a script that reads the staging table and inserts into the dependency tables first. Then when you insert into the main table, the dependencies will already exist.

    ______________________________________________________________________________
    How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.

  • Thank you for the info..

Viewing 5 posts - 1 through 4 (of 4 total)

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