Knowledge Base

FIX: Unable to Truncate a Table That Had a Constraint Defined

Article ID: 156287

Article Last Modified on 10/16/2003


APPLIES TO


This article was previously published under Q156287
BUG #: 15572 (6.0), 15405 (6.5)

SYMPTOMS

The TRUNCATE statement fails with the following error message:
Msg 4712, Level 16, State 1
Cannot truncate table '<tablename>' because it is being referenced by a
foreign key constraint.

Deleting from the table produces the following error:
Msg 439, Level 16, State 1
Unable to find foreign key constraints for table '<tablename>' in dbid
'x' though table is flagged as having them.

WORKAROUND

To work around this problem, do the following:
  1. Back up the database.
  2. Drop and re-create the table.

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server versions 6.0 and 6.5. This problem has been corrected in U.S. Service Pack 2 for Microsoft SQL Server version 6.5. For more information, contact your primary support provider.

MORE INFORMATION

This problem occurs if the table once had a constraint defined, but the constraint was later removed by the ALTER statement.

Keywords: kbbug kbfix kbnetwork KB156287