I am attempting to modify a XML data type field with the SQL update statement below. I am having trouble setting the correct path past the level /Operand xsi:type="QueryObjectKey"/
to reach the /Name/
field. I can set the path to modify parent fields/values like /GroupBegin/false/GroupBegin/
with no problem, so I know the SQL statement is correct, just the path syntax to reach /Name/
is not right.
I get this ambiguous error message
Msg 2205, Level 16, State 1, Line 6
XQuery [ACVSCore.Access.Query.XMLEncodedCriteria.modify()]: ")" was expected.
How do I set that path to include the /Operand xsi:type="QueryObjectKey"/
DECLARE @NewValue Varchar(255) = 'None'
update
[ACVSCore].[Access].[Query]
SET
XMLEncodedCriteria.modify('replace value of
(/QueryExpression/Criteria/CriteriaExpression/Operand xsi:type="QueryObjectKey"/Index/text())[1] with sql:variable("@NewValue")')
<QueryExpression xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" PrimaryObjectType="SoftwareHouse.NextGen.Common.SecurityObjects.Personnel" DataFetcherType="SoftwareHouse.CrossFire.Common.Objects.DataQuery">
<DataFetcherTag xsi:type="xsd:string" />
<Criteria>
<CriteriaExpression>
<GroupBegin>false</GroupBegin>
<Operand xsi:type="QueryObjectKey">
<Name>ORIGINAL</Name>
</Operand>
</CriteriaExpression>
</Criteria>
</QueryExpression>