Cannot truncate table because it is being referenced by a FOREIGN KEY constraint?

Posted by ctrlShiftBryan on Stack Overflow See other posts from Stack Overflow or by ctrlShiftBryan
Published on 2008-10-31T15:06:41Z Indexed on 2010/06/14 17:32 UTC
Read the original article Hit count: 377

Using MSSQL2005, Can I truncate a table with a foreign key constraint if I first truncate the child table(the table with the primary key of the FK relationship)?

I know I can use a DELETE without a where clause and then RESEED the identity OR

Remove the FK, truncate and recreate but I thought as long as you truncate the child table you'll be OK however I'm getting a

"Cannot truncate table 'TableName' because it is being referenced by a FOREIGN KEY constraint."

error.

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about sql-server-2005