Personalized Community is here!
Quickly customize your community to find the content you seek.
Check out the latest Sales updates!Learn about the key capabilities and features of Dynamics 365 Sales and experience some of the new features.
Download overview guide | Watch Sales video
2021 Release Wave 2Discover the latest updates and new features releasing from October 2021 through March 2022.
2021 release wave 2 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
Dynamics CRM works largely on FetchXML queries. FetchXML is a proprietary query language for Dynamics CRM. For developers coming from SQL background, they would really want to find the SQL query that the FetchXML translates into. While one way is to explain the FetchXML syntax, it might help to also get the SQL statement that the CRM Platform converts into.
SQL Tracing is what comes to the rescue here. Using SQL Tracing, you can find all the SQL queries that get executed in the background when running CRM application.
Note: SQL Tracing can only be executed for CRM On-Premise systems.
Take an example where we have a below Fetch XML based query that is generated using advance find.
Follow the below steps to get the SQL Query for the above.
To create a new trace click on File -> New Trace.
In this way you will get the SQL query from the fetch XML.
exec sp_executesql N’select
top 51 “account0″.Name as “name”
, “account0″.PrimaryContactId as “primarycontactid”
, “account0″.Telephone1 as “telephone1″
, “account0″.AccountId as “accountid”
, “account0″.PrimaryContactIdName as “primarycontactidname”
, “account0″.PrimaryContactIdYomiName as “primarycontactidyominame”
Account as “account0″ (NOLOCK)
(( “account0″.CreatedOn >= @CreatedOn0 and “account0″.CreatedOn <= @CreatedOn1 )) order by
, “account0″.AccountId asc’,N’@CreatedOn0 datetime,@CreatedOn1 datetime’,@CreatedOn0=’2010-05-03 07:00:00′,@CreatedOn1=’2014-05-03 11:52:49.553′
You can see from the SQL query, there is hardcoded date for condition i.e. Created on date on Last X Year.
There are built in SQL functions to query CRM data. In this case you can use “dbo.fn_LastXYear(,)”.
Use this to understand the SQL query behind any CRM operation performed from the UI.
To generate FetchXML for a SQL query you have in hand you can use the online tool available athttp://www.sql2fetchxml.com/ from KingswaySoft
Business Applications communities