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
1
vote
1 answer

Using sql:column function in xpath in values method

I have two tables: One called @settings with xml values Another called @nodesToFind with a list of nodes to extract from the xml values in the first table I want to get a list of the values for each NodePath for each RowId. This query uses the…
1
vote
1 answer

How do I use an XQuery result list as a relational table in SQL Server 2008?

I have a table with an XML column: declare @xmltest xml; set @xmltest = ' 1 one 2 two ' Using XQuery, I can extract all the x's: select…
1
vote
3 answers

SQLXML - Search and Query node element?

I have an XML like this stored in an XML datatype column (will have multiple such rows in table)-
Angshuman Agarwal
  • 4,796
  • 7
  • 41
  • 89
1
vote
1 answer

TDE - Remove schema name and view name in column name

I'm trying to create an simple SQL TDE template for XML documents in Marklogic DB. Sample template:
Antony
  • 183
  • 8
1
vote
0 answers

SQL Server OPENXML v XQUERY Performance

I've been testing both OpenXML and XQuery and OpenXML is out performing XQuery by a lot (I believe it should be the other way around from what I have been reading) I prefer to use XQuery so I'm looking for some help. Any way to improve the Xquery? I…
DC07
  • 293
  • 5
  • 18
1
vote
1 answer

sql xml order processor

I was wondering if anyone could point me to a tutorial or give me suggestions on processing an XML "Request For Quote" document. Using SQL Server 2005. For example:
XYZ Wood&
mac
  • 65
  • 1
  • 8
1
vote
1 answer

How can grouping be done to the following code/grouping be done in XML data

select first name ,last name ,employeeID ,CASE WHEN CONVERT(xml,detail).value('count(//education/item)','nvarchar(50)')=0 AND …
palum
  • 233
  • 1
  • 5
  • 13
1
vote
1 answer

SQL - Cast Column as XML then Query Value from said column

I have a column with a bunch of unformatted XML code. I am trying to really just query 1 value out of the column. The value inside of the column is listed below:
Kjbojang1es
  • 47
  • 2
  • 8
1
vote
2 answers

XQuery and Node Ids

I have this variable: declare @xmlDoc XML it has the following xml stored in it: shared sahre Good…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
1
vote
2 answers

Get the parent xml node based on an inner node's value in SQL Server

declare @xmlVal xml set @xmlVal = ' ABC1232013-06-16 18:48:50.111 XYX4562014-01-01 18:48:50.111 ' I need the entire token node as xml where…
Tony Thomas
  • 398
  • 7
  • 20
1
vote
2 answers

filtering result set using xquery on xml sql column

I'm having trouble figuring out how to filter this snippet of xml. I would like to get the svcProvNbr where the userServiceCde = OASV
bubk
  • 11
  • 1
1
vote
1 answer

Inserting an attribute on multiple nodes in incrementing order

I have a XML column in a SQL Server table. I want to add an attribute to the nodes present in the XML. That attribute will be a unique identifier to the nodes. I have written some code like: DECLARE @i int, @key varchar(20); SET @key = 'key' SET @i…
richa verma
  • 247
  • 2
  • 13
1
vote
1 answer

Find child where parent IS NOT a certain element

I'd like to find an empty organisation element where it is not the immediate child of a parentProblem element. Like so.. select * from Audit.PatientAudit pa where pa.BeforeXml.exist('//*:organisation[not(../*:parentProblem)]') = 1 But it doesn't…
Dog Ears
  • 9,637
  • 5
  • 37
  • 54
1
vote
3 answers

How to get child of xmlelement in sql query without its name?

In sql server xml column I have xml like this: 1
bizon
  • 2,406
  • 2
  • 25
  • 28
1
vote
1 answer

How to parse multiple namespaces xml in sql query

I have a table which includes an XML column and I'm trying to fetch certain columns from the XML data. Those columns are under the PositionRoles tag which is part of an has INSERT statement. Unfortunately, I'm getting NULL values. Here is the XML…
Barış ERDOĞAN
  • 109
  • 2
  • 12