Skip to main content

Posts

Showing posts from 2015

Disable and Enable all database constraint.

F rom my data migration experience ,  I have worked a large project from scratch, where user already using a legacy system. We develop a new system with new technology. One of the big task was Data migration, where customer requirement was to migrate legacy data to new system. our new database is Relational database, for this case we need to disable all constraint and migrate data and finally enable all constraint -- disable all constraints EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all" -- enable all constraints EXEC sp_msforeachtable @ command1 = "print '?'" , @ command2 = "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"