Sometimes it could be annoying to turn on database tracing in Dynamics Ax 2012, you will get a lot of useless stuff. A way to only get to know your query is by using the new operator GENERATEONLY, but make sure you disable caching on the table otherwise you will get nothing. See example below: