Straight out of the MSDN docs for Sql Server 2005:
You cannot use TRUNCATE TABLE on tables that:
- Are referenced by a FOREIGN KEY constraint.
- Participate in an indexed view.
- Are published by using transactional replication or merge replication.
I want the effect of a TRUNCATE
(specifically the fact that it resets IDENTITY
type columns), but I can't use one in my case because my table is referenced by a foreign-key elsewhere in the database.
Update: This is for a testing configuration where I am clearing out the referencing table as well, so foreign-key integrity is a non-issue.
What other ways are there to get around this?