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

Passing parameters in nested XML in SQL Server

I have an xml file like below. The xml query with main branch teacherdetails can be a single object or multiple ones. Inside teacherdetails students count is represented in b and student list is presented as nested object.
0
votes
1 answer

querying an XML list in sql server using Xquery

I have a table in SQL server that is used to store submitted form data. The form fields for each submission are dynamic so the collected data is stored as name value pairs in an XML data column called [formdata] as in the example below... This works…
carrot_programmer_3
  • 915
  • 3
  • 14
  • 28
0
votes
2 answers

BaseX XQuery command to get XML file name

I have multiple XML files in a BaseX database: Is there a XQuery or BaseX function to get the file name? In the example above i wanted an other query that returns DB03.xml as output.
user5924595
0
votes
1 answer

Shredding XML column data into rows in SQL

I have an xml value 1John 5James I am able to shred the above xml into tables of ID and Name column using the below query Declare @X xml select…
user6462369
0
votes
1 answer

XQuery [modify()]: The namespace prefix 'dt' has not been defined

I am trying to update an existing XML column value in SQL Server. declare @xml xml; select @xml = ' Item1 '; set @xml.modify('insert
workvact
  • 613
  • 2
  • 8
  • 14
0
votes
1 answer

Getting multiple XML values from SQL

I have a table called 'views' containing data pulled from the Microsoft Service Manager database. To simplify this question, I'll say that this table has 2 columns: Views ---------- ViewId (uniqueidentifier) ConfigXML (xml) A sample of the XML…
MB263
  • 107
  • 1
  • 6
0
votes
1 answer

Running XQuery on a text field that's been CAST to XML

I'm trying to use XQuery on text data that I've cast to XML, without success. So this fails: DECLARE @myDoc TEXT SET @myDoc = ' 1…
Eric
  • 2,861
  • 6
  • 28
  • 59
0
votes
2 answers

Equivalent to like in XQuery?

I am trying to get all titles that contain a certain word from my database in XQuery in SQL I would use WHERE title LIKE '%England%' - I am wondering how to do this in XQuery? My XQuery query looks like this: (:Selects document:) for $x in doc…
BradleighJL
  • 43
  • 1
  • 8
0
votes
1 answer

Comparing XML values in database works for changes but not additions

I'm trying to compare XML data in order to determine what has been changed or added. If a singular record is changed, or more than one change happens in the same order, it returns the expected result. However if a new record is added, it doesn't…
Syntax Error
  • 1,600
  • 1
  • 26
  • 60
0
votes
0 answers

why is Xquery converting Vbcrlf to Vblf?

data data1 data3 Rowid1 data data2 data4
IT researcher
  • 3,274
  • 17
  • 79
  • 143
0
votes
1 answer

How to use a variable inside a function in SQL Server

In brief, I am trying to use a variable inside a SQL Server function that increases its own value by one on each round inside the While loop. I am taking an xml text into a variable and trying to retrieve a value inside an attribute, but it has more…
0
votes
1 answer

How to modify values while extracting them from XML data in SQL Server

Here is a question on XQuerying in SQL (SQL Server 2008) Originally, I have an XML that I need to need to output somewhat differently, for reference: declare @XMLNODE table (id int identity, doc xml) insert @XMLNODE (doc) values ( '
Loser Coder
  • 2,338
  • 8
  • 42
  • 66
0
votes
1 answer

Change value of a xml root node attribute

I am trying to modify the attribute of an XML root attribute in XQuery with T-SQL but I don't manage to do that. My XML has a namespace in it and I can't exactly bypass this. When I query the value of the xml I successfully retrieve the value…
R3muSGFX
  • 63
  • 4
  • 12
0
votes
1 answer

How to update oracle XML datatype in table through Xquery

While updating oracle xml data in table am getting below error. SQL Error: ORA-18126: XUDY0027 - Invalid target expression 18126. 00000 - "XUDY0027 - Invalid target expression" *Cause: Target expression of an INSERT, REPLACE, or RENAME…
Mahesh
  • 198
  • 2
  • 16
0
votes
2 answers

XQuery a SQL Server NVARCHAR column

I have a table with a nvarchar column which stores XML. I'm trying to find all rows which has a specific node empty Here is the structure of the table JOB: ID NVARCAHR(64) NAME NVARCAHR(128) ExtraInfo NVARCAHR(MAX) Here is a…
Matthieu Ducorps
  • 170
  • 1
  • 1
  • 16