Convert FetchXML to SQL query

Some time we need to get SQL query for fetchxml. For MS CRM application you can get FetchXML‘s SQL query by running profiler on SQL server and find the query from profiler.
But if there are more users accessing CRM, then there are lot of queries are executing and we need to go through each query and need to relate to our fetchXML.
This tool converts existing entities system view FetchXML queries to SQL queries. Also you can enter directly fetch XML and it will convert to SQL query.
  1. Convert System View FetchXML to SQL query
* First select Entity from drop down
* Select system view, FetchXML of selected view will be converted to SQL query.
* Click on Get FetchXML, FetchXML for selected view will be retrieved from CRM and displayed in Textbox
* If required you can modify fetch xml as per requirement
* Click on Get SQL query, your FetchXML will be converted to SQL query and shown in textbox.


  1. Manual FetchXML to SQL
* Enter FetchXML in first text box, you want to convert into SQL query
* Click on Get SQL query, FetchXML converted and shown in textbox.


  • User or Team filters
  • Based on current user all conditions are shown.
  • If any filter condition for user and/or userteam, then current user id and user teams will be retrieved and Id’s will be shown in SQL query.


  • Date time operator
    • Most of the time showing CRM database functions in SQL query. Because date time is varying based on user settings.



For some of the date time operators it is very hard to find exact value. So just showing what will be the possible values.
e.g. Operator = last-x-fiscal-periods, every CRM might have different fiscal period setting, so user need to put those dates.

Last edited May 5, 2015 at 5:23 PM by mahadeomatre, version 6