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-04-25 : 16:32:06
|
| Hello,Is this the correct way to update an xml field?BUT, the error is:XQuery [@Sample.xml.modify()]: Invalid entity referenceThanksdeclare @Sample table(UNID varchar(50),[xml] XML)INSERT @SampleSELECT 'x12345','<stringList xmlns="http://schemas.myCompany.com/myProject/[app]/stringList/1.0"><value>value1</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 amp; 2</value></stringList>' UNION ALLSELECT 'x6789', '<stringList xmlns="http://schemas.myCompany.com/myProject/[app]/stringList/1.0"><value>value & 4</value><value>value1</value><value>value5</value><value>value2</value></stringList>'select * from @SampleUPDATE s SET [xml].modify(' declare default element namespace "http://schemas.myCompany.com/myProject/[app]/stringList/1.0"; replace value of ((/stringList/value[.="&"]/text())[1]) with "&" ')FROM @Sample as sSELECT * FROM @Sample |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-26 : 04:24:08
|
Of course it is ok to ask both here and there!I personally just don't want to spend time on this question if already answered on another forum. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2009-04-26 : 16:38:49
|
| Hi,It is not answered as yet.Question 1)This is what I am trying to do now but the error is:Do you know why?XQuery [Profile.Issuer.modify()]: 'text()' is not supported on simple typed or 'http://www.w3.org/2001/XMLSchema#anyType' elements, found 'element({http://schemas.mycompany.com/myproject/[app]/stringList/1.0}:value,xs:string) *'.------------------------------------------------declare @NewDescription varchar(1000)set @NewDescription = 'Alliance & Leicester Group Treasury plc'UPDATE p SET Issuer.modify(' declare default element namespace "http://schemas.mycompany.com/myproject/[app]/stringList/1.0"; replace value of ((/stringList/value[.="Alliance & Leicester Group Treasury plc"]/text())[1]) with sql:variable("@NewDescription") ')FROM Profile AS pwhere p.ProfileID = 1074496Question 2)I can not manually modify the value of the xml field in the table. How can I manually do this?Thanks |
 |
|
|
|
|
|
|
|