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

 

ERROR MESAGGE:

“Cannot truncate table because it is being referenced by a FOREIGN KEY constraint.”

EXPLANATION:

If you try to delete the contents of a table referenced as a FOREIGN KEY in another table with the TRUNCATE TABLE command, you will receive this message.

SOLUTION:

If you want to delete the contents of a table that you reference as a FOREIGN KEY by another table then you can use the DELETE FROM command.

Alternatively, if you remove the FOREIGN KEY relationship then you can use the TRUNCATE TABLE command.

Msg 4712, Level 16, State 1, Line 1

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

Ekrem Önsoy
Author: Ekrem Önsoy

The original article was written in Turkish by Ekrem Önsoy and translated to English by dbtut with the consent of the author. The copyright of the article belongs to the author. The author shall not be liable in any way for any defect caused by translation.

Leave a Reply

Your email address will not be published. Required fields are marked *