Questions tagged [xml-dml]

The XML Data Modification Language (XML DML) used Microsoft SQL Server 2005 and above to manipulate data in an XML field.

XML Data Modification Language (XML DML) is an extension of the XQuery language. XML-DML keywords include - insert - delete - replace value of

XML DML is similar to Oracle XU (XQuery Update).

63 questions
8
votes
3 answers

TSQL 2005, XML DML - Update Two Values at once?

Is there any way to combine these two replace values with 1 update statement? UPDATE dbo.MyTable SET MyXmlColumn.modify('replace value of (/node/@att1)[1] with "1"') WHERE id = 1 UPDATE dbo.MyTable SET MyXmlColumn.modify('replace value of…
TrevDev
  • 1,106
  • 11
  • 24
7
votes
3 answers

How to delete an attribute from an XML variable in sql server 2008?

I have a table called XML (in SQL Server 2008) and it has a field called XmlDocument of type XML. I am trying to to delete an attribute from an XML variable. Here is how my xml looks like
BumbleBee
  • 10,429
  • 20
  • 78
  • 123
5
votes
3 answers

Inserting an attribute in multiple XML Nodes using XML.modify() in SQL 2005

I have an @XML document created from a single select statement.
user65035
  • 53
  • 1
  • 4
5
votes
1 answer

How to prevent XML-DML modify function adding empty namespaces to the inserting nodes

So basically I have a script that updates XML based on whether such node exists or not. Here's the t-sql DECLARE @newJob XML SET @newJob = N' job-name ' ;WITH XMLNAMESPACES(DEFAULT…
Mike
  • 561
  • 1
  • 5
  • 20
4
votes
1 answer

Error: The target of 'replace value of' must be a non-metadata attribute or an element with simple typed content

I have the following xml field in which I need to replace the value of one of the nodes:
David Koleno
  • 53
  • 1
  • 3
4
votes
1 answer

How to use XML.modify 'replace value' with a WHERE clause

I have an XML column that contains foreign key ID values stored within XML. I need to be able to update the XML when the ID value changes (e.g. change all instances of "26" to "999"). From my readings here I've tried to adapt the code, but it…
EvilDr
  • 8,943
  • 14
  • 73
  • 133
3
votes
2 answers

XPath in T-SQL update schema

In my table I have a column with XML data. For example lets say that schema is as below: Problem is that some of these nodes has got additional node Now I would like to update all elements…
gruber
  • 28,739
  • 35
  • 124
  • 216
3
votes
1 answer

SQL Server XML file update the value of one node where text of other node is XXX

Here is the XML I have in my Table Field 3
Naveen
  • 111
  • 1
  • 9
3
votes
1 answer

Using Xquery to replace a node value that is xsi:nil = "true"

I am trying to use XQuery in SQL Server 2005 to update xml saved in a column. Here is a sample of the data I need to update. 3 5 6 I need to set the…
Nate Stelzner
  • 33
  • 1
  • 6
3
votes
1 answer

How can I use XQuery to update an attribute value in an XML variable?

Trying to update one attribute in the XML contained in a variable: set @x.modify('declare namespace abc="http://abcsystems.com/"; replace value of (/abc:App/abc:Client/abc:Addresses/abc:PostalAddress)[@AddressLine1] with "555 Service Rd."') Tried…
ajeh
  • 2,652
  • 2
  • 34
  • 65
3
votes
2 answers

T-SQL XML Update with XML fragment from another linked table

I am looking for a way to update (.modify('insert into..') to be specific) an XML column in a table with xml fragments from another table linked by a foreign key. For example, my table structure looks like below (simplified): Fields 1 to 5 in each…
Jay
  • 1,980
  • 1
  • 13
  • 23
3
votes
2 answers
3
votes
3 answers

SQL Server 2008: Rename an element using XML DML?

Is it possible to use an XML DML statement to rename an element in an untyped XML column? I am in the process of updating an XML Schema Collection on an XML column and need to patch the existing XML instances by renaming one element before I can…
Sam
  • 6,167
  • 30
  • 39
3
votes
1 answer

XML DML (Xpath) query to disallow dupliacte columns. It should test if a column exist before inserting into it

update serializedvalue set value.modify(' insert StronglyTyped Immediate false
StackOverflowVeryHelpful
  • 2,347
  • 8
  • 34
  • 46
2
votes
2 answers

SQL Server XML-DML how to replace element value with value of relative xpath

I have an xml column with the following data: adf Alan Turing asdf Vandelay Industries asdf
Seth Reno
  • 5,350
  • 4
  • 41
  • 44
1
2 3 4 5