Friday, May 25, 2012

How to get table name and number of records in each table in AOT

Today, I came across a requirement to find out the name of each table in AOT along with the number of records for each table.
Here is the code to achieve this functionality;

void getTableNameRecordCount(Args _args)
    #AOT Name name;
    NumberOf recordCount;
    TreeNode treeNode;
    SysDictTable sysDictTable;
    treeNode = TreeNode::findNode(#TablesPath);
    treeNode = treeNode.AOTfirstChild();
    while (treeNode)
        name = treeNode.AOTname();
        sysDictTable = SysDictTable::newTableId(treeNode.applObjectId());
        recordCount = sysDictTable.recordCount(false);
        if (recordCount)
        info (strfmt("@SYS26868", name, recordCount));
        treeNode = treeNode.AOTnextSibling();

1 comment:

  1. the code worked very well, its very useful, thank you.


I will appreciate your comments !

Download large bacpac (sandbox database) to DEV environment much faster

As the LCS website gets slower and slower and the database backups get bigger and bigger.  Use AZCopy to download objects out of LCS asset l...