{"id":3504,"date":"2018-05-15T20:36:40","date_gmt":"2018-05-15T20:36:40","guid":{"rendered":"https:\/\/zappysys.com\/blog\/?p=3504"},"modified":"2025-09-19T12:52:33","modified_gmt":"2025-09-19T12:52:33","slug":"ssis-dynamics-crm-read-import-crm-365-onpremises","status":"publish","type":"post","link":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/","title":{"rendered":"SSIS Dynamics CRM \/ Dataverse &#8211; Read \/ Import data into SQL Server"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-3577 alignleft\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png\" alt=\"\" width=\"178\" height=\"160\" \/><\/a>Today Microsoft Dynamics CRM \/ Dataverse (Dynamics 365 \/ On-Premises CRM \/ PowerApp) is one of the most popular CRMs in the world. SSIS Dynamics CRM \/ Dataverse (Dynamics 365 \/ On-Premises CRM \/ PowerApp) read operation can be achieved using <a href=\"https:\/\/zappysys.com\/products\/ssis-powerpack\/ssis-dynamics-crm-source-connector\/\" target=\"_blank\" rel=\"noopener\">Dynamics CRM \/ Dataverse Source Connector<\/a>. It allows connecting to <strong>Dynamics CRM \/ Dataverse 365 Online<\/strong> or <strong>On-Premises Installation<\/strong> \/ <strong>Hosted<\/strong> CRM instance (IFD &#8211; internet facing deployment). You can read data from Dynamics CRM \/ Dataverse using SSIS connector and then exports to other sources (e.g. SQL Server, Oracle or Flat File).<\/p>\n<p>In this new article, we will show how to connect and download the Dynamics CRM \/ Dataverse 365 (Online) data using <a href=\"https:\/\/zappysys.com\/products\/ssis-powerpack\/ssis-dynamics-crm-source-connector\/\" target=\"_blank\" rel=\"noopener\">Dynamics CRM \/ Dataverse Source Connector<\/a>, how to query CRM data using <strong>FetchXML<\/strong> in SSIS and how to use variables in CRM FetchXML Query.<\/p>\n<p>&nbsp;<\/p>\n<h2>Requirements for SSIS Dynamics CRM \/ Dataverse (Dynamics 365 \/ On-Premises CRM \/ PowerApp) read component<\/h2>\n<ol>\n<li>First, you will need SSDT installed<\/li>\n<li>Second, You will need to install <a href=\"https:\/\/zappysys.com\/products\/ssis-powerpack\/\" target=\"_blank\" rel=\"noopener\">ZappySys SSIS PowerPack<\/a> which includes an SSIS Dynamics CRM \/ Dataverse Source (Dynamics 365 \/ On-Premises CRM \/ PowerApp) task.<\/li>\n<li>Finally, a Microsoft Dynamics account<\/li>\n<\/ol>\n<h2>SSIS Dynamics CRM \/ Dataverse Source &#8211; Video Tutorial<\/h2>\n[youtube https:\/\/www.youtube.com\/watch?v=zl0ecdjuLGk?rel=0&amp;showinfo=0&amp;w=560&amp;h=315]\n<h2>Getting started with\u00a0SSIS Dynamics CRM \/ Dataverse read component<\/h2>\n<h3>Register Dynamics CRM \/ Dataverse App obtain App Id \/ Client Secret<\/h3>\n<p>The very first step to access Microsoft Dynamics CRM \/ Dataverse 365 API is to obtain Application Id (also referred as Client Id)\u00a0 and Client Secret. We will use this information later in this article (on OAuth connection UI).<br \/>\n<a href=\"https:\/\/zappysys.com\/blog\/register-app-dynamics-crm-365-cds-dataverse-api-azure-ad-oauth\/\" target=\"_blank\" rel=\"noopener\">Register Dynamics CRM \/ Dataverse App With Azure<\/a>\u00a0and get the credential (App Id, Client Secret).<\/p>\n<h3>Configure Dynamics CRM \/ Dataverse Connection<\/h3>\n<ol>\n<li>\n        In the connection manager, press the new button to create a new connection:<\/p>\n<p>        <div id=\"attachment_3560\" style=\"width: 756px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/create-a-new-connection.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3560\" class=\"size-full wp-image-3560\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/create-a-new-connection.jpg\" alt=\"SSIS create a new connection CRM Dynamics\" width=\"746\" height=\"403\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/create-a-new-connection.jpg 746w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/create-a-new-connection-300x162.jpg 300w\" sizes=\"(max-width: 746px) 100vw, 746px\" \/><\/a><p id=\"caption-attachment-3560\" class=\"wp-caption-text\">SSIS create a new connection CRM Dynamics<\/p><\/div>\n    <\/li>\n<li>\n        Select the ZS-DYNAMICS-CRM Connection.\u00a0 We will use a CRM Online connection, username, password, and organization:<br \/>\n        <div class=\"su-note\"  style=\"border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#fff8b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">NOTE: Please check the Discovery and ORG Service URL are the same as your organization URL. And if you are using Customize URL make sure that you are using it in both Discovery URL as well as in ORG Service URL\u00a0also.<\/div><\/div>\n<p>        <div id=\"attachment_3559\" style=\"width: 775px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2021\/11\/dyanamics-crm-connection-using-oauth-clientid-connect-dataverse-api.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3559\" class=\"size-full wp-image-3559\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2021\/11\/dyanamics-crm-connection-using-oauth-clientid-connect-dataverse-api.png\" alt=\"SSIS Dynamics CRM \/ Dataverse credentials\" width=\"765\" height=\"633\" \/><\/a><p id=\"caption-attachment-3559\" class=\"wp-caption-text\">SSIS Dynamics CRM \/ Dataverse credentials<\/p><\/div>\n    <\/li>\n<\/ol>\n<h3>How to create a Dynamics CRM \/ Dataverse Source<\/h3>\n<ol>\n<li>In the control flow, drag and drop the data flow:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full\" src=\"https:\/\/zappysys.com\/onlinehelp\/ssis-powerpack\/scr\/images\/drag-and-drop-data-flow-task.png\" width=\"460\" height=\"155\" \/><\/li>\n<li>\n        Drag and drop the ZS Dynamics CRM \/ Dataverse Source:<\/p>\n<p>        <div id=\"attachment_3510\" style=\"width: 653px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-dynamics-crm-source.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3510\" class=\"size-full wp-image-3510\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-dynamics-crm-source.jpg\" alt=\"ssis Dynamics CRM \/ Dataverse source\" width=\"643\" height=\"392\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-dynamics-crm-source.jpg 643w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-dynamics-crm-source-300x183.jpg 300w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><\/a><p id=\"caption-attachment-3510\" class=\"wp-caption-text\">SSIS Dynamics CRM \/ Dataverse source<\/p><\/div>\n    <\/li>\n<li>\n        Second, select the connection created before and select the account table:<\/p>\n<div id=\"attachment_3509\" style=\"width: 896px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3509\" class=\"size-full wp-image-3509\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account.jpg\" alt=\"ssis entity table account\" width=\"886\" height=\"603\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account.jpg 886w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account-300x204.jpg 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account-768x523.jpg 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><p id=\"caption-attachment-3509\" class=\"wp-caption-text\">SSIS entity table account<\/p><\/div>\n<p>        &nbsp;\n    <\/li>\n<\/ol>\n<h3>Configure SQL Server Destination<\/h3>\n<p>In the following example, we will show how to export the data from the account entity to SQL Server.<\/p>\n<ol>\n<li>\n        First, drag and drop the OLEDB Destination and join with our ZS CRM Dynamics source:<\/p>\n<p>        <div id=\"attachment_3516\" style=\"width: 334px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-source-dynamics-sql-destination.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3516\" class=\"size-full wp-image-3516\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-source-dynamics-sql-destination.jpg\" alt=\"ssis source dynamics sql destination\" width=\"324\" height=\"202\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-source-dynamics-sql-destination.jpg 324w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-source-dynamics-sql-destination-300x187.jpg 300w\" sizes=\"(max-width: 324px) 100vw, 324px\" \/><\/a><p id=\"caption-attachment-3516\" class=\"wp-caption-text\">SSIS source dynamics SQL destination<\/p><\/div>\n    <\/li>\n<li>\n        Make sure to select the account table from Dynamics:<\/p>\n<p>        <div id=\"attachment_3517\" style=\"width: 896px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account-1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3517\" class=\"size-full wp-image-3517\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account-1.jpg\" alt=\"ssis entity table account\" width=\"886\" height=\"603\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account-1.jpg 886w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account-1-300x204.jpg 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-entity-table-account-1-768x523.jpg 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><p id=\"caption-attachment-3517\" class=\"wp-caption-text\">SSIS Dynamics CRM \/ Dataverse read entity table account<\/p><\/div>\n    <\/li>\n<li>\n        In addition, select an SQL Server and a database. In the name of the table, we will create a table with the following columns:<\/p>\n<pre class=\"lang:tsql decode:true \">CREATE TABLE [crm dynamics] (\r\n[accountcategorycode] nvarchar(255),\r\n\r\n[accountid] uniqueidentifier,\r\n[accountnumber] nvarchar(20),\r\n[accountratingcode] nvarchar(255),\r\n[accountratingcodename] nvarchar(255),\r\n[address1_addressid] uniqueidentifier,\r\n[address1_city] nvarchar(80),\r\n\r\n)<\/pre>\n<p>        <div id=\"attachment_3548\" style=\"width: 834px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-oledb.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3548\" class=\"size-full wp-image-3548\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-oledb.jpg\" alt=\"ssis oledb sql server\" width=\"824\" height=\"719\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-oledb.jpg 824w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-oledb-300x262.jpg 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-oledb-768x670.jpg 768w\" sizes=\"(max-width: 824px) 100vw, 824px\" \/><\/a><p id=\"caption-attachment-3548\" class=\"wp-caption-text\">SSIS OLEBD SQL Server<\/p><\/div>\n    <\/li>\n<li>\n        Go to the mapping page to map all the source and destination columns:<\/p>\n<p>        <div id=\"attachment_3518\" style=\"width: 834px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-import-data.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3518\" class=\"wp-image-3518 size-full\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-import-data.jpg\" alt=\"dynamics import data SSIS Dynamics CRM \/ Dataverse read\" width=\"824\" height=\"663\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-import-data.jpg 824w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-import-data-300x241.jpg 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-import-data-768x618.jpg 768w\" sizes=\"(max-width: 824px) 100vw, 824px\" \/><\/a><p id=\"caption-attachment-3518\" class=\"wp-caption-text\">SSIS Dynamics CRM \/ Dataverse read mapping<\/p><\/div>\n    <\/li>\n<\/ol>\n<h3>Load Dynamics CRM \/ Dataverse Data to SQL Server<\/h3>\n<ol>\n<li>\n        Execute the package:<\/p>\n<p>        <div id=\"attachment_3563\" style=\"width: 703px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-start-package.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3563\" class=\"size-full wp-image-3563\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-start-package.jpg\" alt=\"ssis start package\" width=\"693\" height=\"79\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-start-package.jpg 693w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-start-package-300x34.jpg 300w\" sizes=\"(max-width: 693px) 100vw, 693px\" \/><\/a><p id=\"caption-attachment-3563\" class=\"wp-caption-text\">SSIS start package<\/p><\/div>\n    <\/li>\n<li>Finally, you can see the data exported in SQL Server. Select the data from the CRM Dynamics table:<\/li>\n<\/ol>\n<div id=\"attachment_3519\" style=\"width: 661px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-results.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3519\" class=\"size-full wp-image-3519\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-results.jpg\" alt=\"Data exported from crm to sql server\" width=\"651\" height=\"275\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-results.jpg 651w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-results-300x127.jpg 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/a><p id=\"caption-attachment-3519\" class=\"wp-caption-text\">Data exported from SSIS Dynamic CRM read<\/p><\/div>\n<h2>How to query Dynamics CRM \/ Dataverse<\/h2>\n<p>You can query Dynamics CRM \/ Dataverse data in two modes (Table mode or Query Mode). To use query mode you have to use a special language called <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\" target=\"_blank\" rel=\"noopener\">FetchXML<\/a> (sorry no SQL support).\u00a0 FetchXML is an XML based query language which can be used to SELECT, FILTER, Aggregate, Transform data from CRM. Not all features from traditional SQL Language Found in FetchXML but basic query features can be implemented by writing FetchXML. Here is an example of typical FetchXML.<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;fetch mapping=\"logical\" version=\"1.0\"&gt;\r\n  &lt;entity name=\"account\"&gt;\r\n    &lt;attribute name=\"accountid\" \/&gt;\r\n    &lt;attribute name=\"name\" \/&gt;\r\n    &lt;attribute name=\"country\" \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute=\"country\" operator=\"in\"&gt;\r\n        &lt;value&gt;USA&lt;\/value&gt;\r\n        &lt;value&gt;UK&lt;\/value&gt;\r\n        &lt;value&gt;INDIA&lt;\/value&gt;\r\n      &lt;\/condition&gt;\r\n      &lt;condition attribute=\"status\" operator=\"like\" value=\"ACT%\" \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<p>Above FetchXML query is equivalent to below SQL query in traditional RDBMS.<\/p>\n<pre class=\"lang:tsql decode:true\">SELECT accountid,name,country \r\nFROM account\r\nWHERE country IN ('USA','UK','INDIA') \r\nAND status LIKE 'ACT%'<\/pre>\n<p>&nbsp;<\/p>\n<p>Now let&#8217;s look at how to build FetchXML queries by UI or by Hand.<\/p>\n<p>&nbsp;<\/p>\n<h3>How to generate a FetchXML query using UI<\/h3>\n<ol>\n<li>\n        The Dynamics CRM \/ Dataverse portal contains an option to create queries visually that can be exported to XML. To do that use the <strong>Advanced Find<\/strong> option in the portal:<\/p>\n<p>        <div id=\"attachment_3564\" style=\"width: 1370px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-fetch-xml.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3564\" class=\"size-full wp-image-3564\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-fetch-xml.jpg\" alt=\"Dynamics CRM \/ Dataverse fetch xml\" width=\"1360\" height=\"403\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-fetch-xml.jpg 1360w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-fetch-xml-300x89.jpg 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-fetch-xml-768x228.jpg 768w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-fetch-xml-1024x303.jpg 1024w\" sizes=\"(max-width: 1360px) 100vw, 1360px\" \/><\/a><p id=\"caption-attachment-3564\" class=\"wp-caption-text\">Dynamics CRM \/ Dataverse fetch XML<\/p><\/div>\n    <\/li>\n<li>\n        For example, we will query the Accounts entity where the account name is A. Datum:<\/p>\n<p>        <div id=\"attachment_3565\" style=\"width: 889px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-365-crm-Create-a-query.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3565\" class=\"size-full wp-image-3565\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-365-crm-Create-a-query.jpg\" alt=\"dynamics 365 crm Create a query\" width=\"879\" height=\"303\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-365-crm-Create-a-query.jpg 879w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-365-crm-Create-a-query-300x103.jpg 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-365-crm-Create-a-query-768x265.jpg 768w\" sizes=\"(max-width: 879px) 100vw, 879px\" \/><\/a><p id=\"caption-attachment-3565\" class=\"wp-caption-text\">dynamics 365 CRM Create a query<\/p><\/div>\n    <\/li>\n<li>\n        Next, we can download the Fetch XML:<\/p>\n<p>        <div id=\"attachment_3566\" style=\"width: 798px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-xml-download.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3566\" class=\"size-full wp-image-3566\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-xml-download.jpg\" alt=\"Dynamics CRM \/ Dataverse xml download\" width=\"788\" height=\"312\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-xml-download.jpg 788w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-xml-download-300x119.jpg 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-xml-download-768x304.jpg 768w\" sizes=\"(max-width: 788px) 100vw, 788px\" \/><\/a><p id=\"caption-attachment-3566\" class=\"wp-caption-text\">Dynamics CRM \/ Dataverse xml download<\/p><\/div>\n    <\/li>\n<\/ol>\n<p>Let\u2019s check some examples about fetch XML:<\/p>\n<h3>SELECT All Columns (*)<\/h3>\n<p>This example shows how to write a simple FetchXML query to select all columns<br \/>\nof the account entity.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT * FROM account<\/pre>\n<p>The option all-attributes show all the attributes. In this case, of the account entity.<\/p>\n<p>To build custom FetxhXML:<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' version='1.0'&gt;\r\n &lt;entity name='account'&gt;\r\n &lt;all-attributes \/&gt;\r\n &lt;\/entity&gt;  \r\n &lt;\/fetch&gt;   \r\n  \r\n<\/pre>\n<h3>SELECT Specified Columns and Alias with\u00a0SSIS Dynamics CRM \/ Dataverse<\/h3>\n<p>This example shows how to write a simple FetchXML query to select two columns and use an alias for column name (e.g. name is renamed to accountname).<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT accountid, name as accountname\r\nFROM account<\/pre>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical'&gt; \r\n\t&lt;entity name='account'&gt;\r\n\t\t&lt;attribute name='accountid'\/&gt; \r\n\t\t&lt;attribute name='name' alias = 'accountname'\/&gt; \r\n\t&lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h3>WHERE (AND conditions)<\/h3>\n<p>This example shows how to write FetchXML query to filter data using multiple conditions (AND).<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"lang:tsql decode:true infopanel \">SELECT * FROM account WHERE revenue &gt; 0 AND name like 'A%'<\/pre>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<br \/>\nFor more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">       \r\n&lt;fetch mapping='logical' version='1.0'&gt;\r\n\t&lt;entity name='account'&gt;\r\n\t\t&lt;all-attributes \/&gt;\r\n\t\t&lt;filter&gt;\r\n\t\t\t&lt;condition attribute='revenue' operator='gt' value='0' \/&gt;\r\n\t\t\t&lt;condition attribute='name' operator='like' value='A%' \/&gt;\r\n\t\t&lt;\/filter&gt;\r\n\t&lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h3>WHERE (OR conditions)<\/h3>\n<p>This example shows how to write FetchXML query to filter data using multiple conditions (OR).<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"lang:tsql decode:true infopanel \">SELECT * FROM account WHERE revenue &gt; 0 OR name like 'A%'<\/pre>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<br \/>\nFor more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' version='1.0'&gt;\r\n\t&lt;entity name='account'&gt;\r\n\t\t&lt;all-attributes \/&gt;\r\n\t\t&lt;filter type='or'&gt;\r\n\t\t\t&lt;condition attribute='revenue' operator='gt' value='0' \/&gt;\r\n\t\t\t&lt;condition attribute='name' operator='like' value='A%' \/&gt;\r\n\t\t&lt;\/filter&gt;\r\n\t&lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h3>WHERE (Mixing AND \/ OR conditions)<\/h3>\n<p>This example shows how to write FetchXML query to filter data using multiple conditions (Mixing AND \/ OR).<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"lang:tsql decode:true infopanel\">SELECT * FROM account \r\nWHERE revenue &gt; 0 AND\r\n    (\r\n     name LIKE 'A%' OR \r\n     name LIKE 'B%'\r\n    )<\/pre>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<br \/>\nFor more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">    \r\n&lt;fetch mapping='logical' version='1.0'&gt;\r\n\t&lt;entity name='account'&gt;\r\n\t\t&lt;all-attributes \/&gt;\r\n\t\t&lt;filter&gt;\r\n\t\t\t&lt;condition attribute='revenue' operator='gt' value='0' \/&gt;\r\n\t\t\t&lt;filter type='or'&gt;\r\n\t\t\t\t&lt;condition attribute='name' operator='like' value='A%' \/&gt;\r\n\t\t\t\t&lt;condition attribute='name' operator='like' value='B%' \/&gt;\r\n\t\t\t&lt;\/filter&gt;\r\n\t\t&lt;\/filter&gt;\r\n\t&lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h3>SELECT DISTINCT (Exclude duplicates)<\/h3>\n<p>This example shows how to write FetchXML query to get distinct records (exclude duplicates).<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT DISTINCT accountid,name FROM account<\/pre>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links:<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' distinct='true' version='1.0'&gt;\r\n\t&lt;entity name='account'&gt; \r\n\t\t&lt;attribute name='accountid' \/&gt;\r\n\t\t&lt;attribute name='name' \/&gt;\r\n\t&lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h3>SELECT TOP using\u00a0SSIS Dynamics CRM \/ Dataverse read<\/h3>\n<p>This example shows how to write FetchXML query to select TOP N rows. This setting may not work if you using preview mode.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT TOP 10 * FROM account<\/pre>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' count='10' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;all-attributes \/&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h3>GROUP BY \/ Aggregate functions<\/h3>\n<p>This example shows how to use aggregate functions such as SUM, MIN, MAX, AVG along with GROUP BY clause. When you use the Aggregate function in SQL Query you can also use an alias for the field. Refer FetchXML help to learn more about aggregate functions.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT AVG(estimatedvalue) AS estimatedvalue_avg, COUNT(name) AS opportunity_count, ownerid AS ownerid\r\nFROM opportunity \r\nGROUP BY ownerid<\/pre>\n<p>You can use COUNT, COUNT(attribute_name), SUM, MIN, MAX, AVG as an aggregate function<\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">       \r\n&lt;fetch distinct='false' mapping='logical' aggregate='true'&gt; \r\n    &lt;entity name='opportunity'&gt; \r\n       &lt;attribute name='estimatedvalue' aggregate='avg' alias='estimatedvalue_avg'  \/&gt; \r\n       &lt;attribute name='name' aggregate='countcolumn' alias='opportunity_count' \/&gt; \r\n       &lt;attribute name='ownerid' alias='ownerid' groupby='true' \/&gt; \r\n    &lt;\/entity&gt; \r\n&lt;\/fetch&gt;<\/pre>\n<h3>INNER JOIN (matching child records)<\/h3>\n<p>This example shows how to write FetchXML query to get account and associated contacts where email is @gmail.com or yahoo.com or hotmail.com and revenue for account is &gt; 10000.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"lang:tsql decode:true infopanel\">SELECT a.name, c.firstname, c.lastname, c.email\r\nFROM account a\r\nINNER JOIN contact c ON a.accountid=c.parentcustomerid\r\n                     AND (c.email LIKE '%@yahoo.com'\r\n                          OR c.email LIKE '%@gmail.com'\r\n                          OR c.email LIKE '%@hotmail.com')\r\nWHERE a.revenue &gt; 10000<\/pre>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='revenue' operator='gt' value='10000' \/&gt;\r\n    &lt;\/filter&gt;\r\n    &lt;link-entity name='contact' from='parentcustomerid' to='accountid' alias='c' link-type='inner'&gt;\r\n      &lt;attribute name='firstname' \/&gt;\r\n      &lt;attribute name='lastname' \/&gt;\r\n      &lt;attribute name='email' \/&gt;\r\n      &lt;filter type='or'&gt;\r\n        &lt;condition attribute='email' operator='like' value='%@yahoo.com' \/&gt;\r\n        &lt;filter type='or'&gt;\r\n          &lt;condition attribute='email' operator='like' value='%@gmail.com' \/&gt;\r\n          &lt;condition attribute='email' operator='like' value='%@hotmail.com' \/&gt;\r\n        &lt;\/filter&gt;\r\n      &lt;\/filter&gt;\r\n    &lt;\/link-entity&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;\r\n\r\n<\/pre>\n<h3>LEFT OUTER JOIN (&#8216;not in&#8217; type query)<\/h3>\n<p>This example shows how to write FetchXML query to find all leads that have no tasks, using an alias.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT lead.FullName\r\nFROM Leads as lead\r\nLEFT OUTER JOIN Tasks as ab\r\n    ON (lead.leadId  =  ab.RegardingObjectId)\r\nWHERE ab.RegardingObjectId is null<\/pre>\n<p>For more information on left outer join syntax check below link<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/dn531006.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/dn531006.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'&gt;\r\n  &lt;entity name='lead'&gt;\r\n    &lt;attribute name='fullname' \/&gt;\r\n    &lt;link-entity name='task' from='regardingobjectid' to='leadid' alias='ab' link-type='outer'&gt;\r\n       &lt;attribute name='regardingobjectid' \/&gt;\r\n    &lt;\/link-entity&gt;\r\n    &lt;filter type='and'&gt;\r\n        &lt;condition entityname='ab' attribute='regardingobjectid' operator='null' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;fetch\/&gt;\r\n\r\n<\/pre>\n<h3>ORDER BY<\/h3>\n<p>This example shows how to write FetchXML query with order by specified for one or more attributes.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT firstname, lastname, email FROM contact\r\nORDER BY lastname ASC, firstname DESC<\/pre>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='contact'&gt;\r\n    &lt;attribute name='firstname' \/&gt;\r\n    &lt;attribute name='lastname' \/&gt;\r\n    &lt;attribute name='email' \/&gt;\r\n    &lt;order attribute='lastname' \/&gt;\r\n    &lt;order attribute='firstname' descending='true' \/&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;    \r\n<\/pre>\n<h3>OPERATOR &#8211; Equal ( = )<\/h3>\n<p>This example shows how to write FetchXML query using equal operator.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT name FROM account WHERE revenue=0<\/pre>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\"> &lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='revenue' operator='eq' value='0' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch   \r\n  \r\n<\/pre>\n<h3>OPERATOR &#8211; Not Equal ( != )<\/h3>\n<p>This example shows how to write FetchXML query using not equal operator.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"lang:tsql decode:true infopanel \">SELECT name FROM account WHERE revenue != 0<\/pre>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='revenue' operator='ne' value='0' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h3>OPERATOR &#8211; Greater Than ( &gt; )<\/h3>\n<p>This example shows how to write FetchXML query using greater than the operator.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"lang:tsql decode:true infopanel\">SELECT name FROM account WHERE revenue &gt; 0<\/pre>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='revenue' operator='gt' value='0' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h3>OPERATOR &#8211; Less Than ( &lt; )<\/h3>\n<p>This example shows how to write FetchXML query using greater than the operator.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"lang:tsql decode:true infopanel \">SELECT name FROM account WHERE revenue &lt; 0<\/pre>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\"> &lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='revenue' operator='lt' value='0' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt; \r\n<\/pre>\n<h3>OPERATOR &#8211; IN (Check for multiple matching values)<\/h3>\n<p>This example shows how to write FetchXML query to find multiple matching values using IN operator.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT name FROM account WHERE name IN ('Microsoft', 'Yahoo', 'Google')<\/pre>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='name' operator='in'&gt;\r\n        &lt;value&gt;Microsoft&lt;\/value&gt;\r\n        &lt;value&gt;Yahoo&lt;\/value&gt;\r\n        &lt;value&gt;Google&lt;\/value&gt;\r\n      &lt;\/condition&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;  \r\n<\/pre>\n<h3>OPERATOR &#8211; NULL (Check for NULL values)<\/h3>\n<p>This example shows how to write FetchXML query to find NULL values (search for records where email not specified).<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT firstname, lastname, email FROM contact WHERE email is NULL<\/pre>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\"> &lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='contact'&gt;\r\n    &lt;attribute name='firstname' \/&gt;\r\n    &lt;attribute name='lastname' \/&gt;\r\n    &lt;attribute name='email' \/&gt;\t\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='email' operator='null' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;\r\n<\/pre>\n<h3>OPERATOR &#8211; NOT NULL (Check for NOT NULL values)<\/h3>\n<p>This example shows how to write FetchXML query to find NOT NULL values (search for records where email not specified).<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT firstname, lastname, email FROM contact WHERE email is NOT NULL<\/pre>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock \">&lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='contact'&gt;\r\n    &lt;attribute name='firstname' \/&gt;\r\n    &lt;attribute name='lastname' \/&gt;\r\n    &lt;attribute name='email' \/&gt;\t\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='email' operator='not-null' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;  \r\n<\/pre>\n<h3>OPERATOR &#8211; LIKE (Pattern search)<\/h3>\n<p>This example shows how to write FetchXML query using LIKE operator to match string by pattern search.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT name FROM account WHERE name LIKE 'zappy%'<\/pre>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='name' operator='like' value='zappy%' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h3>OPERATOR &#8211; NOT LIKE (Pattern search)<\/h3>\n<p>This example shows how to write FetchXML query using LIKE operator to match string by pattern search.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT name FROM account WHERE name NOT LIKE 'zappy%'<\/pre>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">  &lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='name' operator='not-like' value='zappy%' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;\r\n<\/pre>\n<h3>OPERATOR &#8211; UNDER (Find all children for given hierarchy)\u00a0with the\u00a0SSIS Dynamics CRM \/ Dataverse read task<\/h3>\n<p>This example shows how to write FetchXML query to get children count for a given hierarchy.<\/p>\n<p>For more information about querying hierarchical data check below link<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/dn817893.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/dn817893.aspx<\/a><\/p>\n<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\">&lt;fetch distinct='false' no-lock='false' mapping='logical'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;attribute name='accountid' \/&gt;\r\n    &lt;attribute name='accountid' rowaggregate='CountChildren' alias='AccountChildren'\/&gt;\r\n    &lt;filter type='and'&gt;\r\n      &lt;condition attribute='accountid' operator='under' value='{0}' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;\r\n<\/pre>\n<h3>Using DateTime Operators\u00a0with the\u00a0SSIS Dynamics CRM \/ Dataverse read task<\/h3>\n<p>This example shows how to write FetchXML query to get all tickets which are created 30 mins before.<\/p>\n<p>Other similar operators are<br \/>\nolderthan-x-hours<br \/>\nolderthan-x-days<br \/>\nolderthan-x-weeks<br \/>\nolderthan-x-months<br \/>\nolderthan-x-years<\/p>\n<p>For a list of supported DateTime operators<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg334216.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg334216.aspx<\/a><\/p>\n<p>For a list of all supported operators check below XSD and search for name=&#8221;operator&#8221;<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock\"> &lt;fetch&gt;\r\n  &lt;entity name='incident'&gt;\r\n    &lt;attribute name='title' \/&gt;\r\n    &lt;attribute name='ticketnumber' \/&gt;\r\n    &lt;attribute name='createdon' \/&gt;\r\n    &lt;attribute name='incidentid' \/&gt;\r\n    &lt;filter type='and'&gt;\r\n      &lt;condition attribute='createdon' operator='olderthan-x-minutes' value='30' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;\r\n<\/pre>\n<h3>Query &#8211; All activities (sort, outer join, alias) with the\u00a0SSIS Dynamics CRM \/ Dataverse read task<\/h3>\n<p>This example shows how to get all activities performed on lead or contact. It shows how to get attributes from lead and contact by using OUTER JOIN.<\/p>\n<p>This FetchXML is the equivalent of below SQL<\/p>\n<pre class=\"infopanel\">SELECT a.*\r\n, l.firstname as lead_name,l.emailadddress1 as lead_email1\r\n, c.firstname as contact_name\r\nFROM activitypointer a\r\nLEFT OUTER JONI lead l ON a.regardingobjectid=l.leadid\r\nLEFT OUTER JONI lead c ON a.regardingobjectid=c.contactid\r\nORDER BY a.createdon DESC<\/pre>\n<p>To build custom FetxhXML<br \/>\n1. Login to your Dynamics CRM \/ Dataverse Portal<br \/>\n2. Click on Advanced Find icon (Found next to the search textbox)<br \/>\n3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM \/ Dataverse Source.<\/p>\n<p>For more information about FetchXML query syntax check below links :<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328117.aspx<\/a><br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg328332.aspx<\/a><\/p>\n<p>For complete syntax and validation rule for FetchXML check below XSD<br \/>\n<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/gg309405.aspx<\/a><\/p>\n<pre class=\"lang:xhtml decode:true codeblock \">&lt;fetch version='1.0' mapping='logical'&gt;\r\n\t&lt;entity name='activitypointer'&gt;\r\n\t\t&lt;attribute name='subject' \/&gt;\r\n\t\t&lt;attribute name='ownerid' \/&gt;\r\n\t\t&lt;attribute name='regardingobjectid' \/&gt;\r\n\t\t&lt;attribute name='activitytypecode' \/&gt;\r\n\t\t&lt;attribute name='scheduledstart' \/&gt;\r\n\t\t&lt;attribute name='scheduledend' \/&gt;\r\n\t\t&lt;attribute name='instancetypecode' \/&gt;\r\n\t\t&lt;attribute name='community' \/&gt;\r\n\t\t&lt;attribute name='actualend' \/&gt;\r\n\t\t&lt;attribute name='createdon' \/&gt;\r\n\t\t\r\n\t\t&lt;link-entity name='lead' from='leadid' to='regardingobjectid' link-type='outer' alias='l'&gt;\r\n\t\t\t&lt;attribute name='firstname' alias='lead_name' \/&gt;\r\n\t\t\t&lt;attribute name='emailaddress1' alias='lead_email1' \/&gt;\r\n\t\t\t&lt;attribute name='companyname' alias='lead_company' \/&gt;\r\n\t\t&lt;\/link-entity&gt;  \r\n\t\t\r\n\t\t&lt;link-entity name='contact' from='contactid' to='regardingobjectid' link-type='outer' alias='c'&gt;\r\n\t\t\t&lt;attribute name='firstname' alias='contact_name' \/&gt;\r\n\t\t&lt;\/link-entity&gt;  \r\n\r\n\t\t&lt;order attribute='createdon' descending='true' \/&gt;\r\n\t&lt;\/entity&gt;\r\n&lt;\/fetch&gt;<\/pre>\n<h2>How to use SSIS variables with Fetch XML in SSIS for SSIS Dynamics<\/h2>\n<h2>CRM read<\/h2>\n<p>You can include variables in an XML fetch.<\/p>\n<ol>\n<li>\n        First, create your variable in the SSDT. Go to SSIS and Variables and create your variable:<\/p>\n<p>        <div id=\"attachment_3514\" style=\"width: 762px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-variable-value.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3514\" class=\"size-full wp-image-3514\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-variable-value.jpg\" alt=\"ssis-variable-value\" width=\"752\" height=\"113\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-variable-value.jpg 752w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/ssis-variable-value-300x45.jpg 300w\" sizes=\"(max-width: 752px) 100vw, 752px\" \/><\/a><p id=\"caption-attachment-3514\" class=\"wp-caption-text\">SSIS variable value<\/p><\/div>\n    <\/li>\n<\/ol>\n<p>In addition, create your fetch, include the variable in the XM ({{User::value}}):<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;fetch mapping='logical' version='1.0'&gt;\r\n  &lt;entity name='account'&gt;\r\n    &lt;attribute name='name' \/&gt;\r\n    &lt;filter&gt;\r\n      &lt;condition attribute='revenue' operator='eq' value='{{User::value}}' \/&gt;\r\n    &lt;\/filter&gt;\r\n  &lt;\/entity&gt;\r\n&lt;\/fetch&gt;\r\n<\/pre>\n<h2>Conclusion about the\u00a0SSIS Dynamics CRM \/ Dataverse read task<\/h2>\n<p>To conclude, we can say that the ZS Dynamic CRM source is a great tool to get data from Microsoft CRM Dynamics and export any other destination format. In this article, we learn how to create queries to CRM Dynamics using fetch data. We used several examples to query data. We also learned to use SSIS variables in our queries and how to export the data from Dynamics CRM \/ Dataverse to SQL Server. <a href=\"https:\/\/zappysys.com\/products\/ssis-powerpack\/download\/\" target=\"_blank\" rel=\"noopener\">Download SSIS PowerPack<\/a> to explore Dynamics CRM \/ Dataverse integration possibilities in SSIS.<\/p>\n<h2>References about\u00a0SSIS Dynamics CRM \/ Dataverse read<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.microsoft.com\/en-us\/dynamics365\/what-is-crm\">What is CRM?<\/a><\/li>\n<li><a href=\"https:\/\/zappysys.com\/products\/ssis-powerpack\/ssis-dynamics-crm-source-connector\/\">SSIS Dynamics CRM \/ Dataverse Source Connector (Dynamics 365 \/ On-Premises CRM)<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Today Microsoft Dynamics CRM \/ Dataverse (Dynamics 365 \/ On-Premises CRM \/ PowerApp) is one of the most popular CRMs in the world. SSIS Dynamics CRM \/ Dataverse (Dynamics 365 \/ On-Premises CRM \/ PowerApp) read operation can be achieved using Dynamics CRM \/ Dataverse Source Connector. It allows connecting to Dynamics CRM \/ [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":3577,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[354],"tags":[352,227,12],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>SSIS Dynamics CRM \/ Dataverse - Read \/ Import data into SQL Server | ZappySys Blog<\/title>\r\n<meta name=\"description\" content=\"This article will show how to extract information from SSIS Dynamics CRM read using SQL Server Integration Services using an SSIS Dynamics CRM task\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"SSIS Dynamics CRM \/ Dataverse - Read \/ Import data into SQL Server | ZappySys Blog\" \/>\r\n<meta property=\"og:description\" content=\"This article will show how to extract information from SSIS Dynamics CRM read using SQL Server Integration Services using an SSIS Dynamics CRM task\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/\" \/>\r\n<meta property=\"og:site_name\" content=\"ZappySys Blog\" \/>\r\n<meta property=\"article:published_time\" content=\"2018-05-15T20:36:40+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2025-09-19T12:52:33+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png\" \/>\r\n\t<meta property=\"og:image:width\" content=\"300\" \/>\r\n\t<meta property=\"og:image:height\" content=\"270\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\r\n<meta name=\"author\" content=\"ZappySys Team\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ZappySys Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"20 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/\",\"url\":\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/\",\"name\":\"SSIS Dynamics CRM \/ Dataverse - Read \/ Import data into SQL Server | ZappySys Blog\",\"isPartOf\":{\"@id\":\"https:\/\/zappysys.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png\",\"datePublished\":\"2018-05-15T20:36:40+00:00\",\"dateModified\":\"2025-09-19T12:52:33+00:00\",\"author\":{\"@id\":\"https:\/\/zappysys.com\/blog\/#\/schema\/person\/91b041e2dcf7ece5f068893c1a68ac6e\"},\"description\":\"This article will show how to extract information from SSIS Dynamics CRM read using SQL Server Integration Services using an SSIS Dynamics CRM task\",\"breadcrumb\":{\"@id\":\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#primaryimage\",\"url\":\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png\",\"contentUrl\":\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png\",\"width\":300,\"height\":270},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/zappysys.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SSIS Dynamics CRM \/ Dataverse &#8211; Read \/ Import data into SQL Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/zappysys.com\/blog\/#website\",\"url\":\"https:\/\/zappysys.com\/blog\/\",\"name\":\"ZappySys Blog\",\"description\":\"SSIS \/ ODBC Drivers \/ API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/zappysys.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/zappysys.com\/blog\/#\/schema\/person\/91b041e2dcf7ece5f068893c1a68ac6e\",\"name\":\"ZappySys Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/zappysys.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/746bec9c9d27f1b90bb181aa516ee234?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/746bec9c9d27f1b90bb181aa516ee234?s=96&d=mm&r=g\",\"caption\":\"ZappySys Team\"},\"sameAs\":[\"https:\/\/zappysys.com\"],\"url\":\"https:\/\/zappysys.com\/blog\/author\/dcalbimonte\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SSIS Dynamics CRM \/ Dataverse - Read \/ Import data into SQL Server | ZappySys Blog","description":"This article will show how to extract information from SSIS Dynamics CRM read using SQL Server Integration Services using an SSIS Dynamics CRM task","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/","og_locale":"en_US","og_type":"article","og_title":"SSIS Dynamics CRM \/ Dataverse - Read \/ Import data into SQL Server | ZappySys Blog","og_description":"This article will show how to extract information from SSIS Dynamics CRM read using SQL Server Integration Services using an SSIS Dynamics CRM task","og_url":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/","og_site_name":"ZappySys Blog","article_published_time":"2018-05-15T20:36:40+00:00","article_modified_time":"2025-09-19T12:52:33+00:00","og_image":[{"width":300,"height":270,"url":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png","type":"image\/png"}],"author":"ZappySys Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"ZappySys Team","Est. reading time":"20 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/","url":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/","name":"SSIS Dynamics CRM \/ Dataverse - Read \/ Import data into SQL Server | ZappySys Blog","isPartOf":{"@id":"https:\/\/zappysys.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#primaryimage"},"image":{"@id":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#primaryimage"},"thumbnailUrl":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png","datePublished":"2018-05-15T20:36:40+00:00","dateModified":"2025-09-19T12:52:33+00:00","author":{"@id":"https:\/\/zappysys.com\/blog\/#\/schema\/person\/91b041e2dcf7ece5f068893c1a68ac6e"},"description":"This article will show how to extract information from SSIS Dynamics CRM read using SQL Server Integration Services using an SSIS Dynamics CRM task","breadcrumb":{"@id":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#primaryimage","url":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png","contentUrl":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/05\/dynamics-crm-365-logo-300x300.png","width":300,"height":270},{"@type":"BreadcrumbList","@id":"https:\/\/zappysys.com\/blog\/ssis-dynamics-crm-read-import-crm-365-onpremises\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/zappysys.com\/blog\/"},{"@type":"ListItem","position":2,"name":"SSIS Dynamics CRM \/ Dataverse &#8211; Read \/ Import data into SQL Server"}]},{"@type":"WebSite","@id":"https:\/\/zappysys.com\/blog\/#website","url":"https:\/\/zappysys.com\/blog\/","name":"ZappySys Blog","description":"SSIS \/ ODBC Drivers \/ API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/zappysys.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/zappysys.com\/blog\/#\/schema\/person\/91b041e2dcf7ece5f068893c1a68ac6e","name":"ZappySys Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/zappysys.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/746bec9c9d27f1b90bb181aa516ee234?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/746bec9c9d27f1b90bb181aa516ee234?s=96&d=mm&r=g","caption":"ZappySys Team"},"sameAs":["https:\/\/zappysys.com"],"url":"https:\/\/zappysys.com\/blog\/author\/dcalbimonte\/"}]}},"_links":{"self":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts\/3504"}],"collection":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/comments?post=3504"}],"version-history":[{"count":56,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts\/3504\/revisions"}],"predecessor-version":[{"id":11473,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts\/3504\/revisions\/11473"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/media\/3577"}],"wp:attachment":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/media?parent=3504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/categories?post=3504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/tags?post=3504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}