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

Query Out XML Data

trying to query out some XML data, the data is structured like the below. (but with far more rows). 1 3 1
0
votes
1 answer

Fetch namespace from XML object in SQL

Consider the following XML
0
votes
0 answers

How to get select columns, columns on condition and where clause from XML query in SQL?

I need a query to insert data into temp table with columns (dbname, schemaname, tablename,query_id, select_cols, join_on, where_clause). These are the cols I required and select_cols, join_on, where_clause columns must retreive from an XML…
user15226334
0
votes
2 answers

How to get the position/index of an ancestor element within the ancestor elements parent

I've got xml that looks like this: true
Jeremy
  • 44,950
  • 68
  • 206
  • 332
0
votes
1 answer

SQL Query to iterate within XML Nodes to check for a value and return the record

One of my database table has multiple records. In each record there is a column which stores the XML of following type . I need to write a query which should fetch the records wherein inside the parent node ,if any of the sub node contains only…
Tom Morris
  • 385
  • 1
  • 4
  • 12
0
votes
1 answer

In xquery when fn:upper-case() with apostrophe ", single quote receiving error

In Xquery for the using the function fn:upper-case when we use apostrophe (') and double quotes (") getting below parser error. please let me know if any inputs on this error. earch failed to execute, please check XQuery for possible issues:…
vinod krishna
  • 101
  • 1
  • 9
0
votes
1 answer

How to use `modify` method on a `ntext` column without changing column type to `xml` (using CAST or CONVERT or other method)

I need to update two attributes in a XML content that is stored in a ntext column called data I tried using the xml.modify XQuery method using a CAST or CONVERT on the data column but did not manage to do it: When trying to use CAST UPDATE…
Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99
0
votes
1 answer

Parsing Xml within t-sql, issue using the XQuery selector from several levels inside the root and parse values from selected nodes

I am very new to parsing values in Xml and was hoping someone with some Xml (XQUERY/XPATH) knowledge would explain to me how to parse certain values from the following Xml using t-sql. I will include the code attempts I have made to show I am not…
0
votes
1 answer

SQL how to extract value from xml string

CREATE FUNCTION split_string_XML ( @in_string VARCHAR(MAX), @delimiter VARCHAR(1) ) RETURNS @list TABLE(NAMES VARCHAR(50)) AS BEGIN DECLARE @sql_xml XML = Cast(''+ Replace(@in_string, @delimiter, '')+ '' AS XML) …
Shani Bhati
  • 171
  • 1
  • 13
0
votes
1 answer

Shredding nested XML data and returning sets

I have xml data with collections nested in multiple levels. DECLARE @xml AS XML SET @xml = ' 1
Matthew Lacey
  • 47
  • 2
  • 6
0
votes
1 answer

XQuery for selecting and grouping

I am trying to export some information out of an xml column. Logic applied: In each part, the actor Name may appear twice. (actor + song) result to a unique combination. Keep only when at aggregation level, scene=1. We don't care about scene=2. We…
Thanasis K
  • 125
  • 6
0
votes
1 answer

Query to remove a tag in XML in SQL Server

I have a xml with name space as follows. How do I remove the tag from the XML using XML query. Can we remove the tag with something like below query. Am not sure how to pass through the tags with SOAP-ENV update tablename set…
Learner
  • 63
  • 7
0
votes
0 answers

SQL Server: Facing problem to parse nested xml element by XQuery

My xml has 4 elements called Sheet, Group, Lineitem and BM 1) there could be multiple Sheet elements but sheet elements will not be nested. 2) Group will be child element of sheet element and Group can be nested means a group can have another child…
Indi_Rain
  • 179
  • 5
  • 17
0
votes
1 answer

How to insert values into a table depending of the XML file attribute with xQuery in SQL Server?

I want to insert the first attributes of the XML always in the same table, but depending of the value of last the XML attributes I have to insert to another table. I have in mind to something like this. But obviously it is wrong. CREATE OR ALTER…
0
votes
1 answer

SQL XPath compare variable with empty XML node

I have the following code: declare @mydoc xml declare @myPhone nvarchar(12) = '2223334445' declare @lastName nvarchar(100) = 'John' declare @myEmail nvarchar(100) = null set @mydoc = '
user2399378
  • 829
  • 2
  • 10
  • 23