Questions tagged [xquery-sql]

the XQuery language as supported by database systems. Include the tag of your system to specify ("sql-server", "oracle", "postgresql", etcetera). Use the "xquery" tag on its own for general questions about XQuery.

XQuery is a query language designed to extract data from arbitrary XML documents. Multiple RDBMSes support XQuery as part of the SQL/XML standard or using proprietary syntax. What follows is a non-exhaustive list.

Microsoft SQL Server

In SQL Server 2005 and onwards, the xml data type methods, in particular .query(), support querying XML and returning the results as relational data. These methods support a subset of XQuery, with special support for some T-SQL specific constructs like variables -- see the XQuery Language Reference for specifics.

Oracle

Oracle includes XML support as Oracle XML DB. It supports XQuery both for querying and updating data, both relational and XML. The XMLQUERY function is used to issue XQuery queries within an SQL statement.

453 questions
3
votes
2 answers

The best way to extract data from xml with xquery

Consider the following xml: There is a need to extract this xml into a relational table: Persons table (Age1 int, Age2 int, Age3 int , Age4 int) Parsing has to satisfy the…
Timofey
  • 2,478
  • 3
  • 37
  • 53
3
votes
1 answer

Convert XML Data to Tabular and XML Form in SQL Server 2005

This is my XML 101 103 105 108
nav
  • 127
  • 1
  • 2
  • 10
3
votes
3 answers

SQL Server 2008 XPath

We're trying to filter a set of XML based on a value we provide. We have the following XML in an XML field with our database, and if passing through the number "5052095050830", we need to find this specific node in the XML. The number we provide may…
ajbrun
  • 161
  • 2
  • 13
3
votes
2 answers

Update Node Value XML T-SQL Based on Value of Other Node at Same Level

I would like to update a piece of xml, which I hold in an variable. I would like to update the value of Value where Name is a given value. Here's a mockup of the xml: TO
High Plains Grifter
  • 1,357
  • 1
  • 12
  • 36
3
votes
1 answer

Add an attribute to the root element

How can I add attribute to the root element of any XML documents which is a column in a table called book this table contains bookid int title varchar(10) Author varchar(10) Order…
up-up
  • 65
  • 8
3
votes
1 answer

Replace attribute name in SQL Server XML

I have a table MyTable with a xml column MyXmlField like this :
user2443476
  • 1,935
  • 9
  • 37
  • 66
3
votes
2 answers

How cast in XML for aggregate functions

In SQL Server 2008. I need execute a query like that: DECLARE @x AS xml SET @x=N'First TextOther Text' SELECT @x.query('fn:max(r/c)') But return nothing (apparently because convert xdt:untypedAtomic to numeric) How to…
renegm
  • 610
  • 2
  • 5
  • 12
3
votes
3 answers

Update(Replace partcial value) XML Column in SQL

I have an XML column in my Table and i wanted to replace particular text wherever it appear in that column with a new text. Here is the xml structure, 1
RaJesh RiJo
  • 4,302
  • 4
  • 25
  • 46
3
votes
3 answers

MIN of XML descendats of date type

How can I query min date of all descendants in XML field. Something like this: DECLARE @xml XML =' 2006-01-01 2016-09-14 2016-09-14
user2065377
  • 448
  • 3
  • 12
3
votes
2 answers

MarkLogic: XQuery to Get Values from XML Documents?

I have the following XML document loaded in MarkLogic database: Writer The First Book Fiction 44.95
happybayes
  • 321
  • 4
  • 12
3
votes
2 answers

Querying values from XML nodes (possible NAMESPACE issue)

I have worked with querying XML and I have what seems like it should be a pretty straightforward query. My data is stored in XML format, such as this: declare @data xml = '
Sam Cohen-Devries
  • 2,025
  • 2
  • 18
  • 35
3
votes
2 answers

Remove XML Nodes for matching attribute condition in SQLServer

I want to remove all the nodes in XML datatype column; matching the attribute condition for all the records.For example node which has attribute "type" whose value is like '%audio%'. Input:
Chat
  • 185
  • 1
  • 5
  • 15
3
votes
2 answers

Separating XML values with the same tags into different rows SQL Server

I have an XML File which I am trying to parse. The XML was created through Excel using Save as XML Because the XML file was created from Microsoft Excel, it has this header:
Sam Cohen-Devries
  • 2,025
  • 2
  • 18
  • 35
3
votes
2 answers

How to optimize a XQUERY in a SELECT statement?

I am using Oracle database. I have a table in which one of the Column is of XMLTYPE. Now, the problem statement is that I need to extract the count of those record that have an XML with a particular root element and one more condition. Suppose the…
systemhalted
  • 818
  • 9
  • 24
3
votes
2 answers

XQuery [nodes()]: The name "s" does not denote a namespace

I have a xml that I need to shred. But I am getting this error XQuery [nodes()]: The name "s" does not denote a namespace. I have xml in following format
Ankur
  • 148
  • 4
  • 14