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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET CONSTRAINTS OFF?

Status
Not open for further replies.

Mongr1l

Programmer
Mar 6, 2006
179
US
Hello.

I'm trying to DTS some tables into a DB. Some of the tables are appends to tables in the destination DB, so I have to first delete the existing records before the new data is appended. However, some of these table are Parent tables in a relationship, complete with foreign key constraints.

Is there a simple way overriding the constraints without having to go to each table and manually dropping them, appending the data, then reapplying them?

Thanks in advance.

mongr1l.
 
This will disable your constraints.
Exec sp_MSForEachTable 'Alter Table ? NoCheck Constraint All'

When your done you will need to re-enable them

Exec sp_MSForEachTable 'Alter Table ? Check Constraint All'

- Paul
- Database performance looks fine, it must be the Network!
 
Remember that the constraints are disabled for everyone while you do this, so don't do it during production hours. It is safest to put the database in single user mode first.

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top