TRUNCATE TABLE doesn't work if the table is dependent of any Foreign Keys

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 344
Assume that table Dept is being referenced by a FOREIGN KEY in Employee table.
If you are trying to truncate the Dept table's data,
TRUNCATE TABLE TableName1


gives the error Cannot truncate table 'dept' because it is being referenced by a FOREIGN KEY constraint

Solution:
In this case, we have to use DELETE statement to delete the records....

Comments or Responses

Login to post response