Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Truncate table problem

Author  Topic 

mavericky
Posting Yak Master

117 Posts

Posted - 2011-07-22 : 11:24:46
Hi All,
When I try to truncate a table, i get a message - Cannot truncate table 'dbo.Customer' because it is being referenced by a FOREIGN KEY constraint.

The same table gets deleted by 'DELETE' easily. Is there any way to figure out which foreign key constraints are preventing the 'TRUNCATE'?

Thanks in anticipation,
Mavericky

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-22 : 11:34:19
you cant apply truncate on a table which is referenced by FOREIGN KEY constraint. you need to use delete.

for finding out FK constraints, have a look at sys.foreign_keys catalog view

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -