Insert data on to tables having PK & FK relations

  • Hi Experts,

    Is there anyway to get the order in which data to be import on to tables when they have primary and Foreign Key relations?

    For ex:We have around 170 tables and when tries to insert data it will throw error stating table25 data should be inserted first when we insert data in table 25 it say 70 like that.

    TIA

  • Silly way is disable all constrains and dump the data.

    @JayMunnangi

  • Thanks Jak,

    Only check constraints can be disabled right?

  • We need to disable triggers on some tables when we bulk-import data (in FKey order)

    ALTER TABLE dbo.MyTable DISABLE TRIGGER ALL

    ...

    ALTER TABLE dbo.MyTable ENABLE TRIGGER ALL

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

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