On several other databases I’ve come across, one can turn off the consistency check when restoring a (scripted) dump of the database. The idea is that when you have dumped the script from a database, you can restore it safely, without doing consistency checks, both to speed things up, and to not be hindered by the order which you stash in the different tables, foreign keys, views etc.
(On Microsoft SQL (2005) you have the ‘generate and publish scripts’.)
Is there such a switch for MS SQL? And obviously, how do you turn it on again – and how can you potentially force a global consistency check afterwards?
PS: I do not necessarily need this feature to execute scripts which the server has produced..!
I dont think it can be donne, but Im not sure.
What can be donne is manually disable the constraint with the code:
and enable it using the same syntax, just change NOCHECK to CHECK
If you really need it to the whole DB you can easly build something to loop through the tables and constraints and execute this code