-
I saw this question on the forum today and after writing an example that demonstrates this, I thought of including it as part of the XQuery Labs . Here is the sample XML we need to process. <userdata pageid="page9" annotationSetId="80"> <notes /> <notes> <note...
Posted to
Jacob's Blog
by
Jacob Sebastian
on
12-14-2010
Filed under:
Filed under: XQuery-Functions, XQuery-Labs, XML, XQuery, TSQL, BRH, XQuery Tutorials, XQuery Lab, XQuery Functions, #XML, #XQUERY, SQL Server - XQuery, #TSQL, #SQL Server, XQuery Training
-
This post aims to be a quick reference source for the beginners and shows a few simple SELECT examples. Reading attributes from an XML variable DECLARE @x XML SET @x = '<author fname="Michael" lname="Howard" />' SELECT @x.value('(/author/@fname)[1]', 'VARCHAR...
Posted to
Jacob's Blog
by
Jacob Sebastian
on
07-01-2010
Filed under:
Filed under: XQuery-Functions, XQuery-Labs, XML, XQuery, SQLSERVER, BRH, XQuery Tutorials, XQuery Lab, XQuery Functions, xquery-lab, #XML, #XQUERY, #TSQL, SQL Server XQuery, XQuery in TSQL, XQuery Training
-
I think it will be quite common that you try to insert a UNICODE value into an XML document and then you see that the INSERT did not work correctly because the value you find within the XML document is slightly different from what you inserted. I got a similar question recently and thought of adding...
-
Most people find it very difficult to deal with XML documents in TSQL as there is no way to run a ‘blind’ SELECT * query on an XML document to get a quick view of the content stored in it. A “select TOP N *” query can quickly give you a few records from the table which will give you an idea about the...
Posted to
Jacob's Blog
by
Jacob Sebastian
on
05-30-2010
Filed under:
Filed under: XQuery-Labs, XML, XQuery, BRH, XQuery Functions, XML Toolkit, XML Library, xquery labs, SQL Server XQuery, XQuery in TSQL, XQuery Training, XQuery Tutorial
-
One of my friends recently sent me the following XML fragment and asked me if I can help writing a query to pull the information out of the XML document. <event name="exception_ring_buffer_recorded" package="sqlos"> <data name="error"> <value>8134</value>...
Posted to
Jacob's Blog
by
Jacob Sebastian
on
03-23-2010
Filed under:
Filed under: XQuery-Functions, XQuery-Labs, XML, XQuery, TSQL, SQL SERVER, CROSS-APPLY, XQuery Functions, SQL Server XQuery, XQuery in TSQL, XQuery Training, XQuery Tutorial
-
This installment of XQuery Labs presents a script that reads information from an RDF document using TSQL and XQuery. 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...
-
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 it. DECLARE @x XML SELECT @x = ' <feed xmlns...
-
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 1 UNION ALL SELECT 2 UNION ALL SELECT 3 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 continued to display the script files in its own order...
-
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" CONTACT ="Michael" /> < CUST COMPANY...
-
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 address information is not stored in separate columns...
-
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. < Employees > < Employee name ="Jacob"...
-
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 this. SQL Server 2005 does not allow inserting XML...
-
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 > < Name > Jacob </ Name > <...
-
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. < Employees > < Employee ID ="1001"...