Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Cast Replace text

Author  Topic 

TRACEYSQL
Aged Yak Warrior

594 Posts

Posted - 2014-01-17 : 16:55:05
I have a table the column is TEXT

The myparameter has

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<myrecord1>true</myrecord1>
<myrecord2>test</myrecord2>
<myrecord5>false</myrecord5>

and I need to update myrecord1 and myrecord5

I am stuck on the casting to make it work...any ideas
--errors Incorrect syntax near the keyword 'where'.

update Test_Table
Set myparameter =
Cast(Replace
(cast(myparameter as nvarchar(max)),
'<MYRECORD1>true</MYRECORD1>' ,
cast('<MYRECORD5>true</MYRECORD5>' as Text)
FROM Test_Table
where MYVALUE = 'TEST'

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-01-17 : 18:15:04
[code]Set myparameter = Cast ( Replace ( cast(myparameter as nvarchar(max)), '<MYRECORD1>true</MYRECORD1>' , '<MYRECORD5>true</MYRECORD5>' ) ) [/code]



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

TRACEYSQL
Aged Yak Warrior

594 Posts

Posted - 2014-01-18 : 00:05:38
Thank you so much
Go to Top of Page
   

- Advertisement -