Get from X++ QUERY to get SQL query using getSQLStatement() for trouble shooting Dynamics AX 2012

 getSQLStatement is a new method that has been introduced in tables in AX 2012. Use getSQLStatement() method to get the SQL query from the X++ query to use for trouble shooting.

The X++ select has been extended with the generateonly command that instructs the underlying data access framework to generate the SQL query without actually executing it.

Code Example:

static void getSQLQuery(Args _args)
{
    CustTable custTable;
    CustTrans custTrans;    
    
    select generateonly firstOnly AccountNum, CustGroup 
        from custTable join custTrans where custTrans.AccountNum == custTable.AccountNum;
    info(custTable.getSQLStatement());
 
}


Comments

Popular posts from this blog

Creating a class, the best practice way in D365F&O

Package Deployment using LCS for Microsoft Dynamics 365 Finance & Operations

How to remove deployed model in Tier2 environment in D365FO