Truncate table - v5 beta
Posted: Thu 24 Sep 2015 14:14
I have seen that trying to Truncate a table in dbForge Studio for SQL Server v5 beta is not very intelligent.
When a table has a foreign key constraint, the program says 'Cannot truncate table 'Xxxxx' because it is being referenced by a FOREGIN KEY constraint' without even looking to see if the referenced table has any data.
It would be more logical, at least, to see if the referenced table has any records before showing the message. In the case no records were found, a constraint violation could not possible occur and the table should be allowed to be truncated.
A super solution would be to check that the table does not have a CASCADING DELETE set and that the actual data being truncated is really referenced therefore causing a constraint violation.
When a table has a foreign key constraint, the program says 'Cannot truncate table 'Xxxxx' because it is being referenced by a FOREGIN KEY constraint' without even looking to see if the referenced table has any data.
It would be more logical, at least, to see if the referenced table has any records before showing the message. In the case no records were found, a constraint violation could not possible occur and the table should be allowed to be truncated.
A super solution would be to check that the table does not have a CASCADING DELETE set and that the actual data being truncated is really referenced therefore causing a constraint violation.