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.
| Author |
Topic |
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2009-05-01 : 05:38:51
|
| Hello,I have managed to come up with a query to update an xml field.Do you know how I can modify this query so that all the occurences of '&' are replaced with '&'Thanksdeclare @Sample table(RowID varchar(50),[xmlField] XML) INSERT @SampleSELECT 'x12345','<stringList xmlns="http://schemas.myCompany.com/myProject/[app]/stringList/1.0"><value>value & 1</value></stringList>' UNION ALLSELECT 'x4321', NULL UNION ALLSELECT 'x9876', '<stringList xmlns="http://schemas.myCompany.com/myProject/[app]/stringList/1.0"><value>value5</value><value>value & 2</value></stringList>' UNION ALLSELECT 'x6789', '<stringList xmlns="http://schemas.myCompany.com/myProject/[app]/stringList/1.0"><value>value4</value><value>value1</value><value>value & 5</value><value>value2</value></stringList>'select * from @Sample----declare @ReplaceWith varchar(10)set @ReplaceWith = '&'UPDATE p SET [xmlField].modify(' declare default element namespace "http://schemas.mycompany.com/myproject/[app]/stringList/1.0"; replace value of ((/stringList/value[.="'&'"])[1]) with sql:variable("@ReplaceWith") ')FROM @Sample AS p |
|
|
|
|
|