Browse by Tags
All Tags »
XQuery-Labs (
RSS)
After reading XQuery Lab 51 , my friend and database expert Brad Schulz send me a note showing another way of achieving the same results. The approach he suggested was much cleaner than my version. My code used the following expression in the WHERE clause...
One of my friends approached me recently with a request to write a TSQL query that reads information from an RDF document. Here is the sample XML document he wanted to process. <RDF xmlns:r="http://www.w3.org/TR/RDF/" xmlns:d="http:...
One of my friends emailed me this morning asking help for reading data from Google Analytics Atom feed, using Query with TSQL. My friend sent me a sample XML document he obtained from Google Analytics and here is the query that reads information from...
We have seen a few examples that demonstrated how to delete elements and attributes from XML documents. In this lab, let us see how to delete rows from a table, based on the data in an XML document. DECLARE @t TABLE (id INT ) INSERT INTO @t(id) SELECT...
I was working on my presentation for 24-hour-pass event on 2nd September and came across the sorting issue with the solution explorer. I have a number of script demos and I wanted to organize them by name. No matter, what I did, the solution explorer...
Welcome to XQuery Lab 47. In this lab, we will see how to generate an HTML table from an XML document, using XQuery. Here is the source data: < CUST COMPANY ="Company1" CONTACT ="Jacob" /> < CUST COMPANY ="Company1"...
I just came across a task to extract ZIP code values from the address column of a table. The address is a single string that contains information such as street, city, state, zip code, apartment number etc. The data comes from a legacy system where the...
One of the readers recently asked me if we could delete an attribute with a specific name from all the elements of an XML document. However, the deletion should occur only if the attribute is at a given position. Here is the sample data for this Lab....
In XQuery Lab 10 we saw how to insert an attribute to an XML document and in XQuery Lab 11 , we say how to insert an element to an XML Document. We have not seen an example that inserts an XML fragment to another XML document. So, let us see how to do...
In XQuery Lab 18 , we saw how to delete an element from an XML variable or column. Let us now see, how to delete more than one element from an XML column or variable. Here is the sample XML that we will examine in this lab. < Employees > < Employee...
I heard this question from many people. Executing a dynamic OPENXML() query is little tricky. Before we look at a dynamic OPENXML() query, let us look at the static version. Here is an example document that we will parse using OPENXML() in this session...
We have seen a number of string parsing/manipulating examples using XQuery and FOR XML in the previous sessions of XQuery Labs . This session presents yet another string parsing example using XML data type methods. Here is the string value that we need...
We saw a number of string manipulation examples using FOR XML and XML Data Type methods. Here is yet another string parsing requirement that we will solve using the XML Data type methods. In this post, we will see how to extract words from strings stored...
I found this question in the MSDN SQL Server XML forum and wrote a query to help the user who posted it. I wanted to write a query using XQuery but could not write it instantly. There does not seem to be an easy way to get the full path of an element...
In some of the previous posts , we saw how to delete an element or attribute from an XML document (variable/column). In this post, let us examine one more example that deletes elements from an XML document matching a given criteria. I wrote this...
More Posts
Next page »