Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
nikhildas
Starting Member
3 Posts |
Posted - 2012-01-18 : 01:26:14
|
| Why should not violate foriegn key while enable in SQL Server?For Eg.,We have two table, Order Header and Order Detail.Order header table OrderID Column referencing to OrderDetail table OrderID column. okey, then i'm going to migrate with some data from production database to these table. i just disable these table foreign key constraint and inserted data from production Db. After insertion of data, Order details table OrderID Column contains the values 101,102,103 but Order header Table Order ID Column contains value 100 only. Then i had enable the foreign key constraint using the following t-sql code exec sp_msforeachtable "ALTER TABLE ? CHECK CONSTRAINT ALL"Why should not violate the foreign key with existing data while enabling? |
|
|
Kristen
Test
22859 Posts |
Posted - 2012-01-18 : 03:51:58
|
| "i just disable these table foreign key constraint and inserted data from production Db."Why? I would just insert the [Order Header] data first, and THEN the [OrderDetail] |
 |
|
|
|
|
|