ODBC Driver for Dynamics 365 translates a subset of SQL-92 SELECT statements into FetchXML, the native query language used by Dynamics 365. Data modification operations like UPDATE, INSERT, and DELETE are mapped to corresponding Dynamics 365 Web API calls.
SQL SELECT statements are translated into FetchXML queries for remote execution.
SQL UPDATE, INSERT, and DELETE statements are translated into Dynamics 365 Web API calls that modify data in the corresponding entities.
To be translatable into FetchXML, a SELECT statement must meet the following requirements:
SELECT clause can include only column names, or the wildcard asterisk (*).FROM clause must contain only one table or joined tables. A JOIN is translatable if:
JOIN clause.INNER JOIN and LEFT OUTER JOIN are supported.
INNER JOIN can be used multiple times for joining multiple tables.LEFT JOIN must be used only in cases where it is the only join in the query.WHERE clause should contain only comparisons of columns and constants or the LIKE operator.AND and OR can be used to combine multiple conditions.ORDER BY and GROUP BY clauses are supported.
ORDER BY can be used for sorting results by fields.GROUP BY can be used for grouping by fields.CASE WHEN) are not translatable into FetchXML.SELECT AccountName, ContactName
FROM Account
INNER JOIN Contact ON Account.ContactId = Contact.ContactId
WHERE Account.City = 'New York'
ORDER BY Account.AccountName;
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="account">
<attribute name="name" alias="AccountName" />
<link-entity name="contact" from="contactid" to="contactid" alias="Contact">
<attribute name="fullname" alias="ContactName" />
</link-entity>
<filter type="and">
<condition attribute="address1_city" operator="eq" value="New York" />
</filter>
<order attribute="name" descending="false" />
</entity>
</fetch>
FetchXML queries executed remotely provide significantly higher performance than local execution. It’s recommended to use translatable SQL queries for best performance, as this minimizes overhead and maximizes the speed of data retrieval.