Now try to truncate the Order Table TRUNCATE TABLE. In the above script we have created a foreign key constraint FK_Order_Customer on the CustID column of the Order table which is referring to the CustID primary key column of the Customer table.ĭisclaimer: As TRUNCATE table removes all the records from the table. Truncate all/all except few/specified Tables of a Database in Sql Server IDENTITY (1, 1) NOT NULL ,ĬONSTRAINT PRIMARY KEY CLUSTEREDĬONSTRAINT FOREIGN KEY To demonstrate this error let us first create a demo db ‘SqlhintsTruncateDemo’, two tables Customer and Order. In this article we will discuss on when we get the error like below in Sql Server and how to resolve it.Ĭannot truncate table ‘Customer’ because it is being referenced by a FOREIGN KEY constraint.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |