I try many commands to disable table restrictions in my database, to truncate all tables, but still now it gives me the same error:
Cannot truncate table '' because the FOREIGN KEY constraint refers to it.
I'll try
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
EXEC sp_MSforeachtable "TRUNCATE TABLE ?"
And I tried this for every table
ALTER TABLE [Table Name] NOCHECK CONSTRAINT ALL
truncate table [Table Name]
ALTER TABLE [Table Name] CHECK CONSTRAINT ALL
and every time I have a previous error message. How can I solve this problem?
source
share