Questions tagged [sqlxml]

SQLXML is a feature in MS SQL (introduced in SQL Server 2000), that enables XML support for making queries and processing data.

SQLXML was introduced in MS SQL Server 2000, and adds support for MSXML library into SQL Server. It allows the user to execute SQL SELECT statements that return XML instead of tabular data. In later versions(from SQL Server 2005), the XML support was extended with adding xml as a type in MS SQL Server to support XPath and XQuery over tables.

More info can be found in SQLXML's page in MSDN: http://msdn.microsoft.com/en-us/library/aa286527.aspx

471 questions
2
votes
2 answers

How do I overcome OpenXML's 8000 character limit?

I'm loading an XML in SQL using OpenXML while declaring the variable the max i can go up to is 8000 chars : DECLARE @xml_text varchar(8000) Since text, ntext is not allowed to be used with openXML what other alternatives do i have to load the…
Murtaza Mandvi
  • 10,708
  • 23
  • 74
  • 109
2
votes
1 answer

Convert C# 2.0 System.Data.SqlTypes.SqlXml object into a System.Xml.XmlNode

I seem to always have problems with converting data to and from XML in C#. It always wants you to create a full XMLDocument object even when you think you shouldn't have to. In this case I have a SQLXML column in a MS SQL 2005 server that I am…
Greg Bray
  • 14,929
  • 12
  • 80
  • 104
2
votes
1 answer

Edit XML with SQL query SQL Server 2008 R2

I have the following problem and hope someone could help. I have a SQL Server database with a couple thousand rows. Every row consist of a column with an ID and a column with XML data. This XML data looks something like:
Jannibal
  • 77
  • 6
2
votes
2 answers

TSQL getting record count and records in single query

I got this tasks table that has TODO items. We are retrieving the todo items and the count of Finished, Pending tasks using separate query in single stored procedure even though it is querying from same table. Here is the query, select TaskName…
Deeptechtons
  • 10,945
  • 27
  • 96
  • 178
2
votes
1 answer

Cast xml to varchar with no entities

This code DECLARE @x xml SET @x = ( SELECT 'A & B > C' FOR XML PATH('') ) PRINT CAST(@x AS nvarchar(1000)) Return: A & B > C How obtain my original string 'A & B > C'? (with no XML entities)
renegm
  • 610
  • 2
  • 5
  • 12
2
votes
2 answers

convert sql xml datatype to table

Given the SQL... declare @xmlDoc xml set @xmlDoc = '
John Livermore
  • 30,235
  • 44
  • 126
  • 216
2
votes
1 answer

How to avoid extra whitespace produced by Teradata's XMLCONCAT and XMLAGG

When using XMLAGG or XMLCONCAT, it seems Teradata adds extra whitespace between the concatenated content: with t (x) as (select 1) select xmlserialize(content xmlconcat(1, 2, 3) as varchar(1000)) a, xmlserialize(content xmlagg(v order by v) as…
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
2
votes
1 answer

How do I set a variable in an UPDATE statement, then use that variable in a xml.modify() statement?

Here is some demo data, and what I imagine the solution would look like: CREATE TABLE #lookup_table ( lookup_key VARCHAR(10), lookup_value VARCHAR(10) ); INSERT INTO #lookup_table ( lookup_key, lookup_value ) VALUES ( 'key1',…
vice
  • 31
  • 6
2
votes
3 answers

SQL Server merges elements in XML, but should be separate elements

I have the following query: SELECT TOP 1 'St. Kulakow 12' AS 'address', 'P123' AS 'address' FROM tab FOR XML PATH ('ROOT') It returns me merged tag 'address', but it should be separate. I get:
St. Kulakow…
user3345547
  • 717
  • 2
  • 6
  • 16
2
votes
1 answer

SQL XML Xquery data query using a variable in the node selection?

I am obviously missing something right in front of me, however I have this SQL 2008 XML query as follows: select distinct cast(customFields_xml.query('data(/root/cf_item_type)') as varchar) as c1 from designs .. what I am actually trying to achieve…
Dav.id
  • 2,757
  • 3
  • 45
  • 57
2
votes
1 answer

Learning how to use SQLXML data types

I've been given the challenging task to become familiar with using SQLXML data types in C# using Microsoft SQLServer. None, of my C# or database books cover this and there are no tutorials I can find on the web. All I've managed to find is an MSDN…
millie
  • 2,642
  • 10
  • 39
  • 58
2
votes
1 answer

XML load is slow. Using text() when reading XML file with attribute-centric mapping

I am reading in an XML file into the database. It works fine however it is very slow. I was wondering if I can use text() in order to speed the process up similarly to the solution in this post: Xml select query xpath is slow. My problem however is…
Alex.S
  • 23
  • 1
  • 6
2
votes
1 answer

Extracting multiple values from a table column previously casted to XML

I have a table column as nvarchar(max)containing the following XML data:
anon
2
votes
2 answers

How to rename the xml root element in SQL

I have a xml variable like this: I want to rename the root to discount, output should be:
Ash
  • 447
  • 2
  • 6
  • 19
2
votes
3 answers

SQL Table result in a xml output

I have a table Key code 1 100 1 200 1 300 1 400 2 100 2 200 2 300 I am looking for my result in one row with key and other row XML_data Key XML_Data(XML column) 1 1... 2 …
AB04
  • 57
  • 1
  • 3