Hi all,
Just wanted to start a discussion on a database issue that I am presented with; the issue is that I am trying to insert seed data into around 90 tables without having to worry about manipulating/disabling the foreign key constraints.

The most logical solution would be to do disable them during downtime or when the application has been brought down, insert the seed data and then re-enable the foreign keys. This solution will not work since say the application needs to be up and online while the inserts/updates are happening.

My intial thought was to use the 'sys.foreign_keys' command and store those into a temp table and thus the reference the data relationships when the inserts are executing. Is this a viable option .. or are there any better/more efficent solutions out there?

Thx :)

You need to prepare your script according to the dependencies. If you can sequence insertion script properly, no problem you will face. You need to study all foreign keys and based on that design which table insert will go first and so on till last table.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.