2015-04-23 43 views
2

我有下面的語句在工作中AX:如何查看X ++ select語句的SQL表達式?

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

我在SQL Server中使用它。我如何將此select語句轉換爲SQL並在SQL Server Management Studio中使用它?

回答

4

爲了調試的目的,你可以改變你的select查詢和你的桌子上使用getSQLStatement方法:

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()); 

這將顯示你的SQL語句無需實際執行該語句。

+2

您還可以添加'forceLiterals'來查看精確值而不是參數。 https://msdn.microsoft.com/en-us/library/aa656402.aspx – Matej

+1

另請參閱http://stackoverflow.com/a/33927010/4509 –