web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Query Expression or Fetch Xml - Equivalent of NOT EXISTS SQL

(0) ShareShare
ReportReport
Posted on by

Hi, I am trying to translate the following SQL query into a query expression or a fetch XML. I know I can get the Raw data from the Opportunity Entity and use LINQ queries to filter out what I need but I would like to know if there is a way to get it done using a query expression or a fetch XML.

SELECT o.OpportunityId
FROM dbo.Opportunity o
WHERE NOT EXISTS
(
    SELECT cbo.New_OpportunityId
    FROM dbo.New_commission cbo
        INNER JOIN dbo.New_commissionreport cr
            ON cr.New_commissionreportId = cbo.New_CommissionReportId
    WHERE cbo.New_OpportunityId = o.opportunityid
          AND cbo.New_Type = 1 -- type new
          AND (cr.New_CommissionPeriodFrom
          BETWEEN '20181001' AND '20181031'
              )
);


Please advise.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    pavanmanideep Profile Picture
    1,331 on at

    Hi Sridhar,

    Please use the below tool to convert your SQL queries to Fetch XML

    SQL TO FetchXML

    However due to limitations of CRM Fetch XML, all the SQL query... Try to start with smaller query and start adding additional conditions while using this tool..

  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi SridharV86,

    You cannot use the NOT EXISTS operator in FetchXML or QueryExpression.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    I would suggest to try to build yoru query using advance find and then you can download the fetchxml.

    us.hitachi-solutions.com/.../great-fetchxml-tool-for-microsoft-dynamics-crm

    Hope this helps.

  • Community Member Profile Picture
    on at

    Thanks for taking time to help. I could not build what I needed in Advanced Find or Fetch XML and ending up getting the raw data from Opportunity Entity and then applied filter.

    Thanks,

    Sridhar

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans