【问题标题】:Guide or any tool to convert FetchXML to SQL Query将 FetchXML 转换为 SQL Query 的指南或任何工具
【发布时间】:2016-06-15 01:52:09
【问题描述】:

我有以下 FetchXML 查询,用于在 Business Intelligent Development Studio 中创建报告。

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="incident">
    <attribute name="ticketnumber" />
    <attribute name="createdon" />
    <attribute name="statuscode" />
    <attribute name="incidentid" />
    <attribute name="caseorigincode" />
    <attribute name="new_statussla" />
    <attribute name="ownerid" />
    <attribute name="new_caseaging" />
    <attribute name="casetypecode" />
    <order attribute="ticketnumber" descending="false" />
    <filter type="and">
<condition attribute="createdon" operator="on-or-after" value="@Startdate" />
    <condition attribute="createdon" operator="on-or-before" value="@Enddate" />
    <condition attribute="caseorigincode" operator="ne" value="3" />
</filter>
<link-entity name="systemuser" from="systemuserid" to="owninguser" visible="false" link-type="outer" alias="a_cf39b8fda77b421483a1af5e511c39ca">
  <attribute name="new_region" />
  <attribute name="businessunitid" />
</link-entity>
 </entity>
</fetch>

我确实将此查询转换为 SQL 查询,如下所示。

SELECT a.ticketnumber, a.createdon, a.statuscode,
a.incidentid, a.caseorigincode, a.new_statussla,
a.ownerid, a.new_caseaging, a.casetypecode,
b.new_region, b.businessunitid
FROM FilteredIncident a, FilteredSystemUser b
WHERE a.ownerid = b.systemuserid
AND createdon >= @StartDate
AND creaedon <= @EndDate
AND caseorigincode != '3'

我的问题,我的 SQL 查询是否正确?虽然我可以执行。

【问题讨论】:

  • 先生。 Shaa 没有将 xml 转换为 sql 的工具,您手动执行此操作,您将在其中制作解析器 ...
  • 你可以试试这个,fetchxml2sql.codeplex.com 或者你可以从 SQL Profiler 中提取它...
  • 旁注:请避免使用旧式连接。显式连接成为 ansi-sql 的一部分已有 20 多年了。欲了解更多信息,read this
  • 好的,谢谢,@ZoharPeled 先生,你能用上面的查询给我看这个例子吗?可以联系我shaaruddin.daud@mason.com.my。
  • 我没有回答你的问题。如果我有,我会把它贴在这里,而不是给你写一封电子邮件。

标签: sql-server reporting-services dynamics-crm fetchxml


【解决方案1】:

出于需要,我刚刚创建了这个。 FetchXML to SQL Convertor在 GitHub 上免费!

正在进行的工作,但将提供可用的输出。试试看! https://github.com/abtevrythng/FetchXML-to-SQL

这是为您的 fetchXML 生成的输出:

SELECT incident.ticketnumber, incident.createdon, incident.statuscode, incident.incidentid, incident.caseorigincode, incident.new_statussla, incident.ownerid, incident.new_caseaging, incident.casetypecode, systemuser.new_region, systemuser.businessunitid 
FROM incident 
LEFT OUTER JOIN systemuser ON incident.systemuserid = systemuser.owninguser
WHERE incident.createdon TBD '@Startdate'  AND incident.createdon TBD '@Enddate'  AND incident.caseorigincode != '3'

【讨论】:

    猜你喜欢
    • 2012-06-16
    • 2017-08-19
    • 2012-04-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-17
    • 1970-01-01
    • 1970-01-01
    • 2016-08-29
    相关资源
    最近更新 更多