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

SQL Server XQuery - iterate dynamic xml and return custom structure

I have below XML in SQL Server and wants to iterate over it in order to generate a structured message.
AAhad
  • 2,805
  • 1
  • 25
  • 42
0
votes
1 answer

Xquery in SQL: Selecting a subset

Given the following xml variable: declare @x xml select @x = '
A 12 B
Omnia9
  • 1,563
  • 4
  • 14
  • 39
0
votes
1 answer

Suggestions: xQuery where filter predicate delivers unexpected results

I have the following xml which is being parsed via a MSSQL database using OPENXML with an xquery filter to grab the right rows. Unfortunately, it doesn't seem to grab the appropriate rows, which has me scratching my head. Using the following XML, I…
Greg
  • 85
  • 1
  • 8
0
votes
2 answers

XML DML query for attribute

declare @myDoc xml set @myDoc = '
markkidduk
  • 13
  • 7
0
votes
1 answer

SQL Server Xquery, cast to decimal with localization it-IT

I have a list of decimal values in XML formatted with italian localization (that is comma as decimal separator and dot as thousands separator) and I have to convert to decimal values. The XML is like this: 2
Radioleao
  • 394
  • 1
  • 4
  • 19
0
votes
0 answers

Sql Server query xml

I need to write an sql query that "extract" all default inline namespace value of a xml columns having the default namespace (inline) that start with a prefix. The xml value is very complex and have a lot of custom ns. Here is an example:
0
votes
1 answer

Xquery delete with Xpath from sql:variable

I am having Xpath to delete from XML in an VARCHAR(MAX) variable, but XML.modify('delete '+@MyXpath) give an error , The argument 1 of the XML data type method "modify" must be a string literal. DECLARE @myXML XML, @MyXpath…
0
votes
1 answer

xQuery Array[*]?

SELECT XMLQUERY ('$x/test/xml[1]/data(@type)' PASSING XMLCOLUMN as "x") type, XMLQUERY ('$x/test/xml[1]/text()' PASSING XMLCOLUMN as "x") text FROM XML I want to select all child-nodes of a parent-node. I am thinking about…
0
votes
3 answers

How to query XML inside a tag?

I am trying to query the value for location with the attribute tag in my xml below. How can I do so? My current query only returns the value for the full attribute tag but I only want the value for location, which in this case is…
java123999
  • 6,974
  • 36
  • 77
  • 121
0
votes
2 answers

Using relative paths within SQL XQuery arithmetic

Is there a simple way to use a relative path within XQuery arithmetic within SQL Server? e.g. with the below code, I'm repeating /a/b/ on both sides of the operator: declare @x xml = '1020' select…
JohnLBevan
  • 22,735
  • 13
  • 96
  • 178
0
votes
1 answer

Manipulating the xml column in sql server using Xquery

I am storing an xml file in the xml datatype in table of SQL Server. Now I want to fetch some fragments (using xquery) and then update the fragments with the modified fragments (using xquery). I need some suggestions. I have the code to delete a…
Varun
  • 37
  • 8
0
votes
1 answer

How can I extract multiple values from an XML column, using a function similar to value()?

I'm trying to extract xml metadata from from SQL Server's Report Server Database. My current query is listed below: SELECT a.Name as 'ReportName' ,a.ReportXML ,Parameter = x.value('(Parameter/Name)[1]','VARCHAR(250)') FROM (SELECT…
SQLUser44
  • 51
  • 2
  • 9
0
votes
1 answer

Comparison operations on xs:boolean in SQL Server 2005

Can anyone explain to me the results of this query: declare @xml xml; set @xml = 'Val'; select T.c.query('xs:boolean(@attribute[1])') Value, T.c.query('xs:boolean(@attribute[1]) = false') ValueEqualsFalse, …
evan w
  • 552
  • 7
  • 15
0
votes
1 answer

How to output XML node with same name[multiple occurrences] but different values using an XQuery

I have a requirement where an XML element node say 'UseCountIds' having multiple occurrences and with multiple values . As element node name remain same, I need to distinguish each of these as UseCountIds1,UseCountIds2,UseCountIds3. As of now, it is…
Tom George
  • 29
  • 1
  • 1
  • 7
0
votes
2 answers

How to output some XML optional elements/nodes always using XQUERY

I have a requirement where I need to output optional XML elements always (irrespective of data availability) , while writing into a .csv file. XML File Format 123
Tom George
  • 29
  • 1
  • 1
  • 7