October 24, 2013 at 8:34 am
Hi Hi Guys,
The following is a Sample OF an XML field I want TO Modify:
DECLARE @TestTAb AS TABLE(ID INT IDENTITY PRIMARY KEY, XMLText XML)
INSERT INTO @TestTAb(XMLText) VALUES(
'
<main>
<heading>"Quotes Should be removed" </heading>
<heading2>"Quotes Should not be removed" </heading2>
</main>
')
INSERT INTO @TestTAb(XMLText) VALUES(
'<main>
<heading>Quotes "Should" be removed </heading>
<heading2>Quotes "Should" not be removed </heading2>
</main>')
What is the easiest way TO do an update on the table and REMOVE ALL the quotes, but ONLY FOR heading 1?
October 24, 2013 at 9:01 am
sharky (10/24/2013)
Hi Hi Guys,The following is a Sample OF an XML field I want TO Modify:
DECLARE @TestTAb AS TABLE(ID INT IDENTITY PRIMARY KEY, XMLText XML)
INSERT INTO @TestTAb(XMLText) VALUES(
'
<main>
<heading>"Quotes Should be removed" </heading>
<heading2>"Quotes Should not be removed" </heading2>
</main>
')
INSERT INTO @TestTAb(XMLText) VALUES(
'<main>
<heading>Quotes "Should" be removed </heading>
<heading2>Quotes "Should" not be removed </heading2>
</main>')
What is the easiest way TO do an update on the table and REMOVE ALL the quotes, but ONLY FOR heading 1?
Something like: -
UPDATE a
SET XMLText.modify('replace value of (/main/heading/text())[1] with sql:column("N")')
FROM (SELECT ID, XMLText, REPLACE(XMLText.value('(/main/heading/text())[1]','NVARCHAR(MAX)'),'"','') AS N
FROM @TestTAb) a;
October 24, 2013 at 9:08 am
Thanks! Perfect..
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply