FIX: Unable to Truncate a Table That Had a Constraint Defined (156287)



The information in this article applies to:

  • Microsoft SQL Server 6.0
  • Microsoft SQL Server 6.5

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.

Modification Type:MajorLast Reviewed:10/16/2003
Keywords:kbBug kbfix kbnetwork KB156287