How to Search X++ Code Using Dynamics AX Model Database(SQL Query)

In MorphX IDE, the ‘Find’ functionality is ‘decent’ and works best if you are searching within an object, like a Class or Table, but if you want to find something across all objects – meaning the entire AOT, it’s probably going to take a long time to search. I lost my patience after waiting for couple hours for the search below to finish… ‘What If’ you could query the Dynamics AX Model Database to find a string across all objects? Well, using the simple SQL Query below, you can. Here’s how to search X++ code using Dynamics AX model database: SELECT RootHandle . Name RootElementName , ElementHandle . Name ElementName , ElementTypes . ElementTypeName Type , CAST ( Sources . SourceText AS nvarchar ( MAX ) ) SourceText FROM Sources Sources JOIN ModelElement ElementHandle ON Sources . SourceHandle = ElementHandle . ElementHandle ...