Quantcast
Viewing all articles
Browse latest Browse all 17314

Check the SQL statement generated from a regular X++ select statement

So here is another small tip based on me reading Inside Microsoft Dynamics AX 2012 R3.

If you want to know what SQL statement the SQL Server query processor generates based on a regular X++ select statement, you can add to the keyord generateOnly to the statement an afterwards call the getSQLStatement method on the record buffer.

Example:
   AccountingEvent         accountingEvent;
   SourceDocumentHeader sourceDocumentHeader;

   select generateonly accountingEvent
   join sourceDocumentHeader
    where sourceDocumentHeader.RecId == accountingEvent.SourceDocumentHeader;

   info (accountingEvent.getSQLStatement());

That turns out something like this:


Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 17314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>