Disable Foreign key constraint on all tables didn't work ?
Posted
by Space Cracker
on Stack Overflow
See other posts from Stack Overflow
or by Space Cracker
Published on 2010-03-20T07:33:38Z
Indexed on
2010/03/20
7:41 UTC
Read the original article
Hit count: 340
sql
|sql-server-2005
i try a lot of commands to disable tables constraints in my database to make truncate to all tables but still now it give me the same error
Cannot truncate table '' because it is being referenced by a FOREIGN KEY constraint.
i try
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
EXEC sp_MSforeachtable "TRUNCATE TABLE ?"
and i tried this for each table
ALTER TABLE [Table Name] NOCHECK CONSTRAINT ALL
truncate table [Table Name]
ALTER TABLE [Table Name] CHECK CONSTRAINT ALL
and every time i have the previous error message .. could any please help me to solve sucha a problem ?
© Stack Overflow or respective owner