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 |
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2006-08-09 : 17:25:06
|
Hi friendsi've a parent table and it has 2 childs.i want to truncate parent table without deleting any rows from childs.yes, i tried disable FK constriant like belowalter table child1 nocheck constraint allalter table child2 nocheck constraint allbut following line gives errortruncate table parentthe error is:Cannot truncate table 'parent' because it is being referenced by a FOREIGN KEY constraint.any ideas on this one?interestingly i get same error even if parent table is empty.am using sql2005 standard edition.Cheers |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-08-09 : 17:41:53
|
You have to drop the FK in order to perform a truncate. If you only want to disable the FK, then you'll need to perform a delete instead.Tara Kizer |
 |
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2006-08-09 : 17:44:55
|
thats what i just figured Tara.am just wondering why it so ??ThanksCheers |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-08-09 : 17:49:57
|
Because that's how Microsoft designed it for data integrity purposes.Tara Kizer |
 |
|
|
|
|