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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans