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

Update Deployment Failed due to Missing MpProvider Module

How to Resolve DVT Script Issues When Applying Quality Updates in LCS for D365FO

how to connect Just in time DB in D365F&O / Connect UAT Database with Dev machine in D365 F&O