We need a tool that can convert a given well-defined SQL query into it's constituent xml form. Can anyone suggest anything of this sort, a free tool would do great help. Also, can you advise whether FetchXML by MS can be used to achieve this?
We can consider this trivial example to illustrate the requirement...
Input:
select emp_name, emp_id from employee_table where emp_sal > 5000
Output:
<query>
<entity name=”employee_table”>
<attribute name=”emp_name” />
<attribute name=”emp_id”/>
<filter>
<condition attribute=”emp_sal” operator =”>” value=”5000”/>
</filter>
</entity>
</query>
We have recently launched a free online converter which can be used to convert SQL script to CRM FetchXML. The converter is available at http://www.sql2fetchxml.com/. Check it out and let me know if you have any questions about the converter.
Read this: SQL to fetch xml...how to ??
Related
I am using XRMToolbox and its tool "Bulk Data Updater" with Microsoft Dynamics CRM. I need to update a boolean value of multiple accounts after searching for them by account number. I believe it requires some type of JOIN.
I believe I have constructed the proper query, but when I try to Bulk Update (see picture), the attribute of the boolean value I need is not listed in the dropdown menu.
When I run this query:
I get the results needed
I get the specific user_id values I need, and I get their status "approved" which is the boolean value I need to change, but I can not edit these values because "approved" attribute is not listed in the dropdown menu
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
<entity name="contact" >
<attribute name="user_id" />
<link-entity name="application" from="applicant" to="contactid" >
<attribute name="approved" />
<link-entity name="contact" from="contactid" to="applicant" >
<filter type="or" >
<condition attribute="user_id" operator="eq" value="0000021" />
<condition attribute="user_id" operator="eq" value="0000055" />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>
When you want to set fields on an account, you need to query accounts, but you query contacts.
You already chose the XrmToolBox plugin to use for bulk update, but the query is not the expected one to update back the results - i.e., you mentioned account but the query only has contact and application entities joined. So obviously the query is not composed from the right direction.
If you want to update the application entity, build the query in FetchXML builder starting from application entity rather than from related contact side.
Or you can build the Advanced find query to use, (or download the fetchxml from there or even save that Adv.find query as CRM view to use in Bulk Data updater) you can simply export/bulk edit the records in Excel online to save back. You can select 250 records at once to Bulk edit wizard or to run Workflow to update.
Every single approach need the parent entity list from query to update the field. Start over.
I am beginner to the C#, I need to insert my XML file to SQL table pro-grammatically XML file have five nodes called root, name, subject, sno and queries, I will listed below
<root>
<name>
MyName
</name>
<subject>
newsubject
</subject>
<queries>
<sno>
1
</sno>
<query>
This is the query one
</query>
</queries>
<queries>
<sno>
2
</sno>
<query>
This is the query two
</query>
</queries>
<queries>
<sno>
3
</sno>
<query>
This is the query three
</query>
</queries>
</root>
I need to add this value to sql server table name member_info
my table design is
name --> varchar(50)
subject-->varchar(75)
sno-->int
queries-->varchar(150)
I tried some basic stuffs for finding the XML file on the specific folder, I don`t have idea how to implement by reading and inserting XML file, Please be gentle I am just beginner.
You have a few options:
You can read the XML nodes before inserting into the database, and
insert normalized table column values.
You can shred the XML in a stored procedure, by passing the XML
string as an input parameter. You can read up on how to shred the XML utilizing the nodes() method, here.
I need some help on converting an xml file to an sql query file. Is it possible to convert it?
<mob_proto isOldStructure="false">
<Mob vnum="101" name="??" localizedname="Cão Selvagem" type="0" rank="0" battle_type="0" level="1" event_type="0" mob_color="0" />
</mob_proto>
Just to give you a sense of how XSLT might be used to do this, consider the following stylesheet:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="text" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:template match="//Mob">
SELECT *
FROM <xsl:value-of select="local-name()" />
WHERE vnum = <xsl:value-of select="#vnum" />
AND name = '<xsl:value-of select="#name" />'
</xsl:template>
</xsl:transform>
This would convert any Mob element to a select query, using 'Mob' as the table name, and filtering on vnum and name as column names. You can play with this here:
http://xsltransform.net/nc4NzQA
The advantages of this approach:
XSLT is a well defined standards based langauge with broad platform support.
XSLT will take care of a lot of XML specific issues very neatly
You could potentially keep all your query transformation logic in one place
Disadvantages:
Your queries will likely be limited to a particular syntax/platform
XSLT can be challenging to learn well and may be difficult for your team to maintain
Another option would be to pass your XML to your database engine. If, for example, you're using SQL Server, you could write a stored procedure that takes an XML parameter and then uses OPENXML (https://msdn.microsoft.com/en-us/library/ms175160.aspx) to extract/parse the XML that is sent in. Postgres also has XML support: http://www.postgresql.org/docs/9.1/static/functions-xml.html, as does Mysql: http://dev.mysql.com/doc/refman/5.5/en/load-xml.html, and Oracle I'm sure does as well.
Advantages to this approach:
May not be as steep a learning curve for a proficient SQL developer who doesn't know XSLT
May be able to easily load data directly into database (either keeping it in XML format or shredding it to tables) more efficiently
Disadvantages:
Support will vary from one DB platform to another
May put additional processing strain on your DB server that could be more efficiently handled by an XSLT processor on another machine (especially if you're dealing with a complex document structure).
Of course, you could also use any number of other custom utilities to do this, but XSLT or SQL XML support are probably your best bets.
In the same was as one can query the information scehema in SQL Server to get a list of all tables and columns for a database, can one get a list of all the reports and the fields they reference in SSRS?
Is there something akin to an information schema on the reporting server?
I have a list of 800 reports for which I need to extract all fields, so I need this automated.
Any help would be appreciated and thanks in advance.
PS I am a novice SSRS user although I have done advanced VBA and MDX queries within SSRS.
You can read them as XML files
Structure is:
<Report>
<DataSet>
<DataSets>
<Query>
<Field Name="Name1">
<DataField>Name1</DataField>
...
</Field>
<Field Name="Name">
...
</Field>
...
whats the best way to handle a complex param in a stored proc?
let me explain a little about the param so its clear what i am trying to do here...
I have a project management app - so i have things like a release, a project and milestones.
A project has a single release and a release has its milestones.
i am adding reporting and need to generate a report that allows users to select any number of releases and any milestones of a release. this will result in a report that shows all the projects that are part of the release and their data for the milestones selected.
since each release has multiple milestones (milestone table) to keep the associations of what milestone was selected in what release i was thinking to have coma separated list like this to pass the UI data to SQL.
release1 | m2, m3, m4
release2 | m2, m7
release3 | m5
as a varchar or maybe xml...
whats the best practice for sending in something like this that has relational data built into the param? am i way off and over thinking the problem?
please tell me there is a simple solution i am not seeing...
XML would be the best way and simplest with least amount of code... see a sample below.
As starter sample:
DECLARE #Param XML
SET #Param = '
<chriteria>
<release id="1">
<milestone id="1" />
<milestone id="2" />
<milestone id="3" />
</release>
<release id="2">
<milestone id="1" />
<milestone id="2" />
</release>
</chriteria>
'
SELECT c.value('../#id', 'INT') AS ReleaseId, c.value('#id', 'INT') AS MilestoneId
FROM #Param.nodes('/chriteria/release/milestone') AS T(c)
SQL Server 2008 has Table Valued Parameters to solve just this problem. For SQL Server 2005, you will have to either pass in a string to parse in the Stored Proc, or have your caller and Stored Proc use some shared (or temporary) table to hold the data to process.