The Table_Truncate() function removes all records from a SQL table, leaving the table structure intact in the database.


Table_Truncate(table table_name)


table table_name – The name of the table from which the records are to be removed.

Return value

An integer corresponding to one of the following values:





The records were removed successfully.


There wasn’t enough memory to complete the operation.


Table not supported.


An unknown error occurred.


A SQL truncate command was successfully generated by Dexterity, but it was unable to be completed at the data source.


The operation couldn’t be completed because a user wasn’t logged into the data source.


This function performs the same function as the delete table statement that uses the delete all functionality, but performs this task differently. Table_Truncate() removes records faster than the delete table statement. However, unlike the delete table statement, it ignores any locks another user may have on records in the table.

If a user executes this function while another user has records from the named table in a client buffer, the second user will continue to see those buffered values even after the table’s records have been deleted. Should the second user save records to the table before this function is successfully completed, those records will be deleted when the command is completed. If the second user saves records to the table after the function is successfully completed, those records will be added to the table.

If the named table isn’t open when Table_Truncate() is executed, it will be opened. If the named table doesn’t exist on the current data source, this function will create it, unless Table_SetCreateMode() was used to prevent tables from being automatically created. If the table can’t be created, the error value 27 is returned from Table_Truncate().

Table_Truncate() should be used with caution since it doesn’t respect locks. It generates a SQL truncate command that is not logged in the database’s transaction log. This may cause records to reappear if the database is restored from a backup. We strongly suggest that you use the delete table statement instead of this function unless you are thoroughly familiar with the implications of issuing a SQL truncate command.

Documentation Feedback