I have one xml as
declare @EventBodyXml xml
set @EventBodyXml ='
<LocationCopied xmlns="http://schemas.datacontract.org/2004/07/someName" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Location xmlns:a="http://schemas.datacontract.org/2004/07/someAnotherName">
<a:Name>SomeLocationName</a:Name></Location>
</LocationCopied>'
I am retrieving location name in @uName variable using below query
declare @uName nvarchar(100)
set @[email protected](
'declare default element namespace "http://schemas.datacontract.org/2004/07/someName";
declare namespace a="http://schemas.datacontract.org/2004/07/someAnotherName";
/LocationCopied/Location/a:Name').value('.', 'nvarchar(100)') ;
Then doing some manipulation with @uName and now want to update @EventBodyXml with new @uName value.
@uName='SomeNewUpdatedValue'
I have tried something like this below
set @EventBodyXml.modify('replace value of (
declare default element namespace "http://schemas.datacontract.org/2004/07/SCS.Domain.BusinessObjectManagement.Contract.EventModel";
declare namespace a="http://schemas.datacontract.org/2004/07/SCS.Domain.BusinessObjectManagement.Contract.ViewModel";
/LocationCopied/Location/a:Name/text() ) with sql:variable("@uName") ') ;
But I am getting error like
Msg 2205, Level 16, State 1, Line 27 XQuery [modify()]: ")" was expected.