2 Options…

  • Use a DELETE without a where clause and then RESEED the identity (or)
  • Remove the FK, truncate the table, and recreate the FK.

TRUNCATE TABLE xxxxxxxx; — Cannot truncate table ‘tblImageReference’ because it is being referenced by a FOREIGN KEY constraint.

DELETE FROM xxxxxxxxxx;

Because TRUNCATE TABLE is a DDL command, it cannot check to see whether the records in the table are being referenced by a record in the child table.

This is why DELETE works and TRUNCATE TABLE doesn’t: because the database is able to make sure that it isn’t being referenced by another record.

Last modified: March 17, 2025

Author

Comments

Write a Reply or Comment