Skip to main content

Truncate a table using X++

· One min read
Max Nguyen
FinOps Ranger

We can use the tableTruncate method from SqlDataDictionary to truncate a table in FinOps, useful for a huge SQL table.

public static void main(Args _args)
DictTable dictTable = new DictTable(tablenum(KA_TBYTDStaging));

if (dictTable && dictTable.enabled())
str sqlTableName =;
SqlDataDictionary sqlTable = new SqlDataDictionary();

if (sqlTable.tableExist(sqlTableName))
new SqlDataDictionaryPermission(methodstr(SqlDataDictionary, tableTruncate)).assert();
sqlTable.tableTruncate(tablenum(KA_TBYTDStaging), false);