I am using Sql Server Management Studio 2008.
When I try to truncate a table using the following command
truncate table MyTable
it gives me an error saying
Cannot truncate table ‘dbo.MyTable’ because it is being referenced by a FOREIGN KEY constraint.
I know I have a foriegn Key in this table.
Now when I do the following
- Right click on table and select
Edit Top 200 Rows - Right on any records from the table
- and hit
Delete, it gets deleted.

I am confused with this behaviour, please can some one let me know how and why this happens and how do I delete using truncate statement.
Thanks
Basicly because there is a difference between
DELETEandTRUNCATEIf you could do that even a simple delete would work for those records. (If there is no reference on them, or if an
ON DELETEstatement is declared on the other table which made the reference to MyTable)With the
TRUNCATEyou can’t do that. It is more then aDELETE. You have to remove theCONSTRAINTfirst and then you can make the Truncate. A Truncate is not allowed on a table which referenced by a forign_key.And for example an other difference a Truncate command reserts the
IDENTITYcolumns as well, but aDELETEnot.Here is a good article about it:
The difference in TRUNCATE and DELETE in Sql Server