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

D365FO – AX – Update Data Entity Target Entity fields with X++

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O