Question

I'm importing data from a legacy application (php + mysql) to a rewritten version (sql server 2008 and mvc3). I'm currently in the middle of writing a db synchronization / conversion package.

The mysql data has primary keys but no foreign keys for some reason and because the data is still relational (despite the lack of foreign keys) my conversion package is using IDENTITY_INSERT ON / OFF. Because the source data has no way of enforcing data integrity I would like to perform integrity check after I perform an insert and turn IDENTITY_INSERT to OFF.

Is there a good way to script that action? Preferably on a table level rather than whole db?

Thanks.

Was it helpful?

Solution

Personally I would determine which data does not have integrity before importing into the new schema. A simple WHERE NOT Exists query on each child table (or what shoul have been ddesigned as a child table) will do that. I would not import data that cannot be tied to a parent record. I would however, create an exception table and move those records into it and have some of the users see if they can figure out what the parent data should be.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top