2016-03-16 114 views
-3
Select OpportunityId 
from opportunity AS c 
    left JOIN (
     select a.opportunitynameid 
     from opportunity o 
      JOIN ApprovalDocument a ON a.opportunitynameid=o.OpportunityId 
    ) AS b ON c.OpportunityId=b.opportunitynameid 
Where b.opportunitynameid IS NULL and statecode=0 
+1

什么粘贴的一部分到存储过程中被困扰你吗? – TZHX

+1

我想象一下可以在Google上轻松找到CREATE PROCEDURE命令的语法和示例。你具体在哪里卡住?你有什么尝试不起作用? – David

+0

[将我的sql查询转换为在crm中的queryexpression或fetchxml]可能的重复(http://stackoverflow.com/questions/35955040/convert-my-sql-query-to-queryexpression-or-fetchxml-in-crm) –

回答

0
Create Procedure mySP_GetOpportunity 
@statuscode int = 0 
As 
Select OpportunityId 
from opportunity AS c left JOIN 
    (select a.opportunitynameid from opportunity o JOIN ApprovalDocument a ON a.opportunitynameid=o.OpportunityId) AS b 
    ON c.OpportunityId=b.opportunitynameid 
Where b.opportunitynameid IS NULL 
and [email protected] 
0

CREATE PROCEDURE Proc_Name AS "query goes here" GO 的更详细的SQL查询参考this