4

I have below statement in a job in AX:

select RecId from pjiTable 
    join pID, Type, PrId from sjTable
    where pjiTable.Prid == sjTable.PrId &&
         (sjTable.Type == PjType::TimeMaterial || sjTable.Type == PjType::FixedPrice);

I have to use it in SQL Server. How can I convert this select statement into SQL and use it in SQL Server Management Studio?

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Raas
  • 261
  • 8
  • 25

1 Answers1

9

For debugging purposes you can change your select query and use getSQLStatement method on your table:

select generateOnly forceLiterals RecId from pjiTable 
    join pID, Type, PrId from sjTable 
    where pjiTable.Prid == sjTable.PrId  &&
         (sjTable.Type == PjType::TimeMaterial || sjTable.Type == PjType::FixedPrice);    
info(pjiTable.getSQLStatement());

This will show you SQL statement without actually executing the statement.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Maxim Lazarev
  • 1,254
  • 12
  • 21
  • 3
    You can also add `forceLiterals` to see exact values instead of parameters. https://msdn.microsoft.com/en-us/library/aa656402.aspx – Matej Apr 23 '15 at 07:52