I have an xml column in my table named 'Content_Html' in which the data would look like:
<root>
<Category>Cover Impression</Category>
<Title>Mystery of the Wolves</Title>
<Month>April</Month>
...
...
</root>
I am trying to replace the element under <Category> from Cover Impression to Cover Impressions, and after the replace, my table with this category should look like
<Category>Cover Impressions</Category>
I checked this article (http://stackoverflow.com/questions/7316712/how-to-rename-xml-node-name-in-a-sql-server) for my question, but not exactly what i am looking for.
Can some one point me in the right direction ?
after suggestions down below i tried this:
declare @newValue XML
select @newValue = 'Cover Impressions'
update dbo.content
set content_html.modify('replace value of (/root/Category/text())[1] with sql:variable("@newValue")')
but giving me "Cannot call methods on ntext" error Thanks,
NTEXT, of course the XML functions won't work! I just assumed it was an XML column (since you said so!) First of all: don't use NTEXT anymore - it's deprecated - if at all, usenvarchar(max)and if it's a column containing XML - USEXML...