first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

SQL Server 2005 t-SQL: The Use of the modify() Method for XML Types; insert text; replace value of; XML Data Modification Language (DML)

DECLARE @xml xml

SET @xml = ' <Root> <Item1 /> <Item2 /> <Item3 /> <Item4 /> <Item5 /> </Root> '

SET @xml.modify (' insert text {"Hello World"} as first into (/Root/Item3)[1] ')

SET @xml.modify (' replace value of (/Root/Item3/text())[1] with "" ')

SELECT @xml

/* This projection produces the original results:

&lt;Root&gt;
  &lt;Item1 /&gt;
  &lt;Item2 /&gt;
  &lt;Item3 /&gt;
  &lt;Item4 /&gt;
  &lt;Item5 /&gt;
&lt;/Root&gt;

Note that the modify() method
uses Microsoft-specific XML DML.
This is not part of the XQuery standard.

For more information, see
“Silent XQuery failures” by Denis Ruckebusch
http://blogs.msdn.com/denisruc/archive/
    2007/04/19/silent-xquery-failures.aspx

For general information, see
“Introduction to XQuery in SQL Server 2005”
http://technet.microsoft.com/en-us/library/ms345122.aspx

*/

mod date: 2007-12-23T06:58:02.000Z