Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turning Off the referential Integrity

Status
Not open for further replies.

manmaria

Technical User
Aug 8, 2003
286
US
I am doing to a conversion into Sql server and we have the schema now in MSS. I like to load the data first then want to turn oN the RI later. Is there a way I can accomplish this?

TIA
 
Alright found it.

--To turn off
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'


--To turn on
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'

Any one where it keeps the relationships to turn back on?

Thanks
 
You will have to script out the relationships for each table. Drop them before the import and create them when you are done.
 
Alright, figured out this too.

What is happening is whenever I run the turn OFF the SP, it changes the DDL to "NO" check constrainst to all the FKs and whenever I run the turn ON the SP, it changes the DDL to CHECK CONSTRAINT.
Very smart.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top