Questions tagged [xquery]

XQuery (XML Query) is the W3C method to Query XML.

Filter by
Sorted by
Tagged with
1
vote
1answer
38 views

Use xQuery to extract attribute values that also exist in SQL variable

XML structure: <ns0:message xmlns:ns0='xxx:testing'> <ns0:field name='AAA'>...</ns0:field> <ns0:field name='BBB'>...</ns0:field> <ns0:field name='VVV'>...<...
0
votes
1answer
25 views

XQquery for specific attribute of all specific elements in XML

I am, looking for a query to get all attribute values "NetAmount" of Element "PRODUCT" from the following samle XML: <ROOT> <CATEGORY name="A"> <PRODUCT NetAmount="10.50"/> <...
3
votes
1answer
28 views

Why is an empty XML node xml datatype not being recognized in this query?

My query seems to not recognize self-closing or empty nodes at all. Shouldn't the empty <td/> node return 'null'? Or an empty string. Even if I place an empty space in the node, it still is ...
7
votes
2answers
95 views

XQuery doesn't update XML data

I am trying to run the script to update an XML column: UPDATE DataImpTable SET serviceData.modify('replace value of (/SMObjInfo/CentralData/SMData/CentralSDItem/ControlData/text())[1] with "9876"') ...
14
votes
3answers
745 views

Concatenate all values of the same XML element using XPath/XQuery

I have an XML value like this: <R> <I>A</I> <I>B</I> <I>C</I> ... </R> I want to concatenate all I values and return them as a single string: ...
6
votes
1answer
634 views

How to split XML array into separate rows (while upholding consistency)

I am working on the database dump of this exact stack exchange section. While I am working on it I have encountered one issue that I am currently unable to solve. In the XML File Posts.xml the ...
6
votes
3answers
604 views

How to query against exact values in XML column set

I have a table that contains 80+ sparse columns along with a column set column, this is a brief example: DROP TABLE IF EXISTS #ColumnSet GO CREATE TABLE #ColumnSet ( Id INT NOT ...
5
votes
1answer
472 views

How to parse query plans to get a count of nested loop operators with unordered prefetch?

My boss wants me to parse a set of query plans stored in a table and to determine how many nested loop operators with unordered prefetching are present in each plan. I only have around 100 query plans ...
0
votes
0answers
123 views

sql server - xQuery Select for each element that exists

I have a bit of trouble querying XML columns. This is part of the query I'm trying to use SELECT pof.pofdata.value('InformacionActo[1]/Vehiculos[1]/Vehiculo[1]/@Marca', 'varchar(max)') AS 'marca', ...
10
votes
2answers
2k views

Return xml sequences where an attribute doesn't contain a specific character

Consider the following simple XML: <xml> <customer name="Max"> <email address="me@you.com" /> </customer> <customer name="Erik"> <email address="erik@...
1
vote
1answer
184 views

Update XML metadata in SQL Server

I'm trying to change the value in the XML metadata using SQL Server. The XML file looks like this: <Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/...
3
votes
1answer
1k views

XML query filter by element name

I have the following structure with a variable number of elements on the 2nd level under root with unknown names: <root> <A>text a</A> <B>text b</B> </root> ...
2
votes
1answer
1k views

Trim a value in an xml column in MS SQL Server

I have a database with an XML column. I am trying to update (trim) an xml value of the xml column. I am running on Windows, SQL Server 2008 Express. I did not find any way to trim directly in Xquery ...
1
vote
1answer
855 views

Select row from non-empty node value in xml column using xml query

I am trying to select the rows from the table by putting the condition on the xml column. The condition like if there is date value on the node ‘Completedon’ in the xml column then select that row. ...
1
vote
1answer
198 views

Xquery, insert, Trigger and no place to squeeze stored procedure

I have a Stored procedure, which is, basically, xquery pulling data from xml and inserting it into multiple tables. Once it's inserting into last of the mentioned tables, the trigger fires up and then ...
2
votes
1answer
136 views

Howto query xml

My source data in a SQL Server table has XML structured data. For each of the source rows I need to query the following sample XML structure in a way that I get a calculated value of all A sub ...
6
votes
1answer
2k views

How to cast a list of values within xquery in SQL Server?

I have the following T-SQL code that I am trying to get to work: IF EXISTS (SELECT * FROM sys.xml_schema_collections WHERE name = 'TST') DROP XML SCHEMA COLLECTION TST; GO CREATE XML SCHEMA ...
4
votes
2answers
9k views

Parsing Typed XML with a default namespace and inconsistent root node

I have a structured, typed xml file. <WebService xmlns="http://www.orbis-software.com/WebSvcCon"> <NewLeads> <OutputSchema> <root xmlns="" type="array"> <item type="...
11
votes
4answers
2k views

Modify XML: attributes into elements

I have an XML column that contains data with similar structure: <Root> <Elements> <Element Code="1" Value="aaa"></Element> <Element Code="2" Value="bbb"&...
10
votes
1answer
2k views

Replace value of strongly typed xml element in SQL Server with XQuery

Given a element, defined within an XML Schema Collection as such: <xsd:element name="xid"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:...
1
vote
2answers
5k views

Improve performance of converting a large xml file (~300 MB) to relational table in SQL Server

So this is what I have so far: --Read xml content into a XML data type variable DECLARE @FileData XML SELECT @FileData = CONVERT(XML, BulkColumn) FROM OPENROWSET(BULK '\\file_path\test.xml', ...
2
votes
1answer
3k views

XMLDB - Nodes to Rows

I have an application that stores XML as XMLType in a table. This is the first time I'm using XMLDB and XMLType features, and was wondering if I could use the results from an XQuery FLWOR expression ...
0
votes
1answer
520 views

Indexing a view with xQuery in it

I'm not sure if this can be done at all but if it can it would be a huge help. I have a system where I am not allowed to make changes to the database structures. I have yet to have code changes put ...
2
votes
2answers
1k views

Possible to optimize SELECT query involving XQuery functions selecting from elements with arbitrary number of child elements

Suppose I have the following XML data, where <root> can have an arbitrary number of <child> children <child> can have an arbitrary number of <grandchild> children <...
-1
votes
1answer
1k views

default value with select case on xml

select case 'NULL' when 'NULL' then 'f' end as out output: f but select case (select (SELECT LEFT(l.list,LEN(l.list)-1) FROM (SELECT o.Reciting_Path + '|' + o.Declaimer +',' AS [text()] ...
2
votes
1answer
1k views

XML queries with case insensitive tag- which is the best query

I had asked question about XML queries with case insensitive tag earlier and i found a solution too. But i also found some other solution. So table was something like DECLARE @myTable TABLE ( yourXML ...
3
votes
2answers
3k views

XML queries with case insensitive tag

I have a requirement where i want XML tags to be case insensitive in my xml queries. For example: DECLARE @myTable TABLE ( yourXML XML ) INSERT INTO @myTable SELECT '<z><a><b>1&...
8
votes
1answer
268 views

IN and NOT IN for XML column

I have a table with a xml column. Xml is similar to <Root> <Row> <user>abc</user> <Rowid>1</Rowid> </Row> <Row> <user>vf</...
0
votes
2answers
39k views

Query to search for a substring in xml

I use below query to search for a substring in whole xml(including node name and node value) SELECT * FROM tablename WHERE ( Charindex('abc',CAST([xmlcolumn] AS VARCHAR(MAX)))>0 ) I want an ...
0
votes
1answer
943 views

xml queries with exist and contains giving unexpected results

I have a query as shown below. DECLARE @tbl TABLE ( id INT, col XML ) INSERT INTO @tbl VALUES (1,'<Root> <Row> <User>xyz</User> <Rowid&...
1
vote
0answers
798 views

Search for string in xml column

I am using sql server 2008 r2 express. I have a table with column name 'xmlmycolumn' which is of datatype xml. I want to search for string in that whole xml. So to do this i am casting column as ...
2
votes
2answers
3k views

Remove scientific notation from an XML column

I have a XML column as shown below: <Root> <Row> <Rowid>1</Rowid> <date>2013-05-06</date> <Balance>1.0002E7</Balance> </Row> </...
4
votes
1answer
2k views

How to Return XML Node Ordinal, or delete node based on element value?

I have an XML document similar to this: <Root> <Sub> <Record> <Guid>aslkjflaksjflkasjfkljsd</Guid> </Record> <Record> <Guid>...