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
0
votes
2 answers

Using Value and Query Xml Methods not returning correct results

I have a table! CREATE TABLE [dbo].[XmlTable]( [XmlId] [int] IDENTITY(1,1) NOT NULL, [XmlDocument] [xml] NOT NULL, CONSTRAINT [PK_XmlTable] PRIMARY KEY CLUSTERED ( [XmlId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,…
0
votes
1 answer

SQL, xQuery: Find duplicates

I have a moderate knowledge of SQL and xpath, but none of xquery. How might I write a query to get all records where the XML contained within one field has two instances of the same element which also contains matching data of a sub element. Let…
Mark W
  • 5,824
  • 15
  • 59
  • 97
0
votes
1 answer
0
votes
1 answer

delete all child nodes after nth child node from xml in sql

I have the following XML structure : 7844454564 12354 455554 87451 360
mayurk
  • 121
  • 2
  • 11
0
votes
2 answers

sum two xml nod with one name but different attribute

I have an sql query. I need to sum two xml nodes with the same names () but different attributes (ident= "1cat" + "3cat"). I can get nodes by their number ([1] and [3]) but I need to sum them by "ident". How can I sum 1Category and 3Category by…
JohnyMotorhead
  • 675
  • 1
  • 9
  • 18
0
votes
3 answers

xquery get node value

I'm trying to get value of cat but it retuns me null. Please, help me to get this value. Thanks in advance! DECLARE @xml XML SET @xml = '
JohnyMotorhead
  • 675
  • 1
  • 9
  • 18
0
votes
1 answer

Performance issue in retriving data from XMLAttribute using Xquery

I have one history table which has information of transaction record of master table, in this table I have used XML column to store that transaction information. Table structure with data looks as follows, In Content XML data are stored as XML like…
Mohmedsadiq
  • 133
  • 1
  • 10
0
votes
1 answer

Search for multiple values in an xml column

Environment: SQL Server 2012. Primary and secondary (value) index is built on xml column. Say I have a table Message with xml column WordIndex. I also have a table Word which has WordId and WordText. Xml for Message.WordIndex has the following…
Yuriy Gettya
  • 693
  • 10
  • 20
0
votes
2 answers

XQuery syntax to account for schema definition

Environment: SQL Server 2012. Say I have a table Message with xml column WordIndex. I also have a table Word which has WordId and WordText. Xml for Message.WordIndex has the following schema:
Yuriy Gettya
  • 693
  • 10
  • 20
0
votes
2 answers

How to read the value of XMLColumn from SQL Server table

I am new to xquery in SQL Server. This the value in ErrorXml column in ReponseRecord table. This is how the sample data for ErrorXML column. Row1: Claim is not in…
Rita
  • 1,237
  • 5
  • 24
  • 46
0
votes
1 answer

Using variable in XQuery expressions

using Xquery, how can I embed variable in an xquery expression on the following xml document. I have the following xml document Picture book Simply Red EU
Lucy
  • 471
  • 4
  • 12
  • 28
0
votes
1 answer

External Variable in XPath

I am trying to use the dynamic Xquery and forming the path using the external variable. My query is: xquery version "1.0-ml"; declare variable $idValue as xs:string external; declare variable $element as xs:string external; for $sectiondiv in…
0
votes
1 answer

"Install" - Saxon

I am trying to "install" Saxon for xquery documents. So I set the Classpath var with the saxon9he.jar as file name and tried in the cmd saxon9he but nothing happened. So I tried to execute a xquery file by: java net.sf.saxon.Query and i…
maximus
  • 11,264
  • 30
  • 93
  • 124
0
votes
1 answer

Sort XML Attributes in SQL

How to sort XML Attributes in SQL? for example for this XML: I want:
ARZ
  • 2,461
  • 3
  • 34
  • 56
0
votes
3 answers

xquery should give me proper closed tags for empty node (sql server 2008)

If I have xml which have following some empty node like following. when I modify/select this xml it returns the empty tags like I want empty tags closed with closing like Can I achieve this ...?
Kash
  • 245
  • 1
  • 4
  • 14