2 Options…
- Use a
DELETE
without a where clause and thenRESEED
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.
Comments